Calling contract functions
Assembly code also allows interaction with other contracts. One of the main use cases is to invoke functions on other contracts and get return value from them. Solidity provides the call
opcode that can call functions in a contract. The signature of the call
opcode is shown here:
call(g, a, v, in, insize, out, outsize)
Here, g
stands for the amount of gas being sent with the call, a
stands for the address of the target contract, v
stands for the amount of Ether being sent in wei denomination, in
stands for the starting memory location containing the data to be sent to the EVM (which comprises the method signature and its parameter values), insize
is the size of data being sent in the hexadecimal format, out
stands for the starting memory location that should store the return data from the call, and outsize
is the size of return data in hexadecimal format.
We will use the call
function to invoke a function in another contract, TargetContract
. This...