chapter19-code-1

PHOTO EMBED

Thu Mar 30 2023 11:29:24 GMT+0000 (Coordinated Universal Time)

Saved by @RareSkills

contract ExampleContract {
	function askTheMeaningOfLife(address source) public returns (uint256) {
		(bool ok, bytes memory result) = source.call(abi.encodeWithSignature("meaningOfLifeAndAllExistence()"));
		require(ok, "call failed");

		return abi.decode(result, (uint256));
	}
}

contract AnotherContract {
	function meaningOfLifeAndAllExistence() public pure returns (uint256) {
		return 42;
	}
}
content_copyCOPY