Skip to content

Instantly share code, notes, and snippets.

@noot
Last active January 8, 2019 19:27
Show Gist options
  • Save noot/ebb6c2801b53706a26c43cef856cc92d to your computer and use it in GitHub Desktop.
Save noot/ebb6c2801b53706a26c43cef856cc92d to your computer and use it in GitHub Desktop.
contract MyContract {
function callContract(address _addr, bytes _data) returns (uint8) {
uint8 result;
uint256 length = _data.length + 32;
assembly {
let x := mload(0x40) // get empty storage location
let ret := call (gas,
_addr,
0, // no wei value passed to function
_data, // input
length, // input size
x, // output stored at input location, save space
0x01 // output size = 1 bytes
)
//result := mload(x)
result := byte(0,x) // grab the first byte of x, since we are using uint8
mstore(0x40, add(x,0x20)) // update free memory pointer
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment