I am trying to convert the assembly code into Solidity given at the link: What is a function Selector The code is trying to invoke the function func(...) of Contract1 given below:
contract Contract1 {
function func(uint256 x, uint8 y) public returns (uint32, uint32) {...}
}
contract Contract2{
/* .......
*/
assembly
{
let success := call(
gas, // pass the remaining gas to the function
dest, // the address of the contract1 instance
0, // pass 0 wei to the function
add(data, 32), // the actual data starts after the length of 'data'
mload(data), // the length of 'data' appears at the first 32 bytes
ret, // the address of the output
8 // the size of the output
)
if iszero(success) {
revert(0, 0)
}
}
/*....*/
}
Is the following statement correct?
(success, errCode, arg1, arg2) =dest.func.value()( uint256(789), uint8(123));
arg1 & arg2 would hold the two values returned by func() of Contract1. Somebody please guide me.
Zulfi.
func()by its name if you have the ABI or a contract instance ofContract1, but in the answer I suppose that you want to call the function using the selector without assembly code. It won't create any confusion because thefallbackfunction is called if the contract doesn't recognise the selector or if no selector is provided. – alberto Jul 01 '19 at 08:31