I've been trying to write a function that takes contractAddress
and bytes functionSignature
as input parameters and returns bytes data
from the static call in inline assembly.
For some reason it keeps returning 0x0
instead of the data
im clearly doing something wrong
function getUintAnswer(address _contractAddress, bytes memory data) public view returns (bytes memory result) {
assembly {
// Call the target contract
let success := staticcall(64000, _contractAddress, data, 4/*input bytes*/, result, 160/*output bytes*/)
// failed
if iszero(success) {
revert(0, 0)
}
}
}
i expected the result to be:
0x00000000000000000000000000000000000000000000000200000000000027fa0000000000000000000000000000000000000000000000000000001bf2c11b5e00000000000000000000000000000000000000000000000000000000639ce2e300000000000000000000000000000000000000000000000000000000639ce2e300000000000000000000000000000000000000000000000200000000000027fa
and got a revert
im trying to extract the second int256
and cast it to a uint256
in the most gas efficient way
and i been stuck trying to figure out how to get the static call to successfully return a value