You can specify the value in the call opcode but delegatecall only lets you specify the gas.


1 Answer 1


When you specify a value, you are transferring ETH from the calling contract to the called contract. But delegatecall doesn't actually switch which contract is running, instead it loads the other contract's code and runs it as if it was the calling contract.

For example, if you call Michael Jordan to dunk the basketball, it makes sense to pass him the basketball at the same time (msg.value) so he can dunk it.

However, if you are delegatecall loading Stephen Curry brain into yours so you yourself can make a three point shot from where you stand, then it's you're body that will be making the shot, and it makes no sense to first pass the ball to Stephen Curry.

  • That's a nice analogy but doesn't CALLCODE also do the same thing (loading in code in context of current address)? Yet with CALLCODE you can specify msg.value too Jun 29, 2021 at 20:06
  • @DylanKerler No, CALLCODE is different from DELEGATECALL ethereum.stackexchange.com/questions/3667/….
    – Ismael
    Jul 6, 2021 at 3:23
  • @Ismael Of course it's different... It's a different opcode. I mean that CALLCODE does the same thing as DELEGATECALL in that it executes code in the context of the calling contract. So why does CALLCODE have the additional parameter? Jul 8, 2021 at 9:55
  • 2
    @DylanKerler An important difference is that CALLCODE changes msg.sender and DELEGATECALL doesn't. It makes sense to support transfers for CALLCODE since there's a sender and recipient.
    – Ismael
    Jul 8, 2021 at 14:02

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.