| 1234567891011121314151617181920212223242526272829 |
- contract a {
- function test() public {
- b v = new b();
- // the following four lines are equivalent to "uint32 res = v.foo(3,5);"
- // Note that the signature is only hashed and not parsed. So, ensure that the
- // arguments are of the correct type.
- bytes data = abi.encodeWithSignature(
- "foo(uint32,uint32)",
- uint32(3),
- uint32(5)
- );
- (bool success, bytes rawresult) = address(v).call(data);
- assert(success == true);
- uint32 res = abi.decode(rawresult, (uint32));
- assert(res == 8);
- }
- }
- contract b {
- function foo(uint32 a, uint32 b) public returns (uint32) {
- return a + b;
- }
- }
|