I wrote a very simple smart contract like this:

contract Test{
    function test1(address payable addr, uint256 value) payable public {

And I compiled it using solc 0.5.7 on Remix. Some of the opcodes related to transfer function are like this:


PUSH 8FC            addr.transfer(value)
DUP3            value
SWAP1           addr.transfer(value)
DUP2            addr.transfer(value)
ISZERO          addr.transfer(value)
MUL             addr.transfer(value)

In this part it is very obvious that 8FC, which is the gas stipend (2300) of transfer and send function in solidity, is lost when it is multiplied by zero. As a result, in debug view of Remix, I see this just before executing the CALL opcode in the stack:

Debug View

According to the Yellow Paper, the first parameter of CALL is gas right? Why here the first parameter of CALL is zero and how solidity ensures that transfer and send only forward 2300 gas?

I found another similar question here, but I still couldn't get the answer from their discussion. Any ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.