1

Reading the documentation on the CALL opcode :

"call contract at address a with input mem[in..(in+insize)) providing g gas and v wei and output area mem[out..(out+outsize)) returning 0 on error (eg. out of gas) and 1 on success"

Where CALL is

call(g, a, v, in, insize, out, outsize)

If I test a contract which uses the transfer function and then check what happens in assembly, I see that the stack does indeed represent the right address a at the first position of the stack and the right value v at the second position of the stack. However, the 0th postion of the stack is set to 0. This would mean 0 gas is sent with this call. In transfer, 2300 gas has to be sent, but this apparently does not happen.

How does this work?

EDIT Contract code

pragma solidity ^0.4.24;
contract Transfer{
function test() public payable {msg.sender.transfer(msg.value);}
}
  • Can you share your code or the specific transaction, please? You are right that it isn't supposed to be that way. – mafrasi2 May 28 '18 at 0:20
  • I am just trying to address(something).call.value(somewei). I wanted to see how this code looked like in assembly hence why it does it like that. But this thus spawns 0x0 as gas argument on EVM. – JBrouwer May 28 '18 at 4:27
  • What instructions are executed directly before the CALL? I just tried it and my compiler puts the GAS instruction right before the CALL, so the value on top of the stack is the whole remaining gas when the execution reaches the call. – mafrasi2 May 28 '18 at 4:49
  • Oh wait I'm stupid. I meant to actually call transfer. You are right when you call normally it forwards all current gas. I will add contract code. – JBrouwer May 28 '18 at 14:37
  • 1
    Hm, it still has a non-zero value on top of the stack for me. Here's a screenshot of the debugger. – mafrasi2 May 28 '18 at 16:00
0

That is highly unlikely... With Solidity 0.4.25, compiling address.call() would give you:

...
gas
call

As you can see, the last parameter pushed on the stack is the total amount of available amount of gas after the execution of the GAS opcode itself.

However, in your example, you are compiling address.transfer(), which, per the Solidity docs, forwards a standard gas stipend of 2300.

  0x8fc
  ...
  dup9  // duplicates 0x8fc=2300
  call

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.