contract ExampleContract { function callAdd(address source, uint256 x, uint256 y) public returns (uint256) { (bool ok, bytes memory result) = source.call(abi.encodeWithSignature("add(uint256,uint256)", x, y)); require(ok, "call failed"); uint256 sum = abi.decode(result, (uint256)); return sum; } } contract Calc { function add(uint256 x, uint256 y) public returns (uint256) { return x + y; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter