Skip to content

Instantly share code, notes, and snippets.

@ayinot
Created May 10, 2018 08:24
Show Gist options
  • Save ayinot/d73da55fb9c01de399f0a2aa99206c6d to your computer and use it in GitHub Desktop.
Save ayinot/d73da55fb9c01de399f0a2aa99206c6d to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.19;
contract Interchain {
bytes public selector;
bytes public destHash;
function withdrawal(bytes32 destHash) returns(bytes4){
return this.withdrawal.selector;
}
function parse(bytes _selector, bytes _destHash) returns (bytes b){
selector = _selector;
destHash = _destHash;
b = strConcat(_selector,_destHash);
}
function strConcat(bytes _a, bytes _b) public returns (bytes){
bytes memory _aa = _a;
bytes memory _bb = _b;
bytes memory ab = new bytes(_aa.length + _bb.length);
uint l = _aa.length;
assembly{
mstore(add(ab,32),mload(add(_aa,32)))
mstore(add(add(ab,32),l),mload(add(_bb,32)))
}
bytes memory b = new bytes(36);
assembly { mstore(add(b, 32), mload(add(ab,32))) }
return b;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment