Last active
January 8, 2019 19:27
-
-
Save noot/ebb6c2801b53706a26c43cef856cc92d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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