1

How is it possible that "DELEGATECALL" with a non-zero value?

Example: https://sepolia.etherscan.io/tx/0xd697d2db1494197496a8e6312c8295131a1df66bdeafd29be85361f2318832ad/advanced#internal

enter image description here

After I tried to debug_traceBlockByNumber that block (6747896) and really found thatenter image description here

Maybe someone has a quick answer, if no - I can share the debug_traceBlockByNumber code snippet to reproduce via rpc-node.

3
  • 3
    no need to share any debugs, the parent call already received the value so it is on the balance of the calling contract already. using msg.value with delegate call has no meaning at all since the balance of contract already contains the value, you could use it to know how much was transferred, though
    – Nulik
    Commented Sep 25 at 18:48
  • @Nulik thanks for the answer Commented Sep 26 at 8:14
  • @Nulik you can post this comment as an answer, with additional info if needed. So that OP can mark it as an answer and anyone can easily find it if needed in the future. Commented Sep 26 at 17:08

1 Answer 1

3

no need to share any debugs, the parent call already received the value so it is on the balance of the calling contract already. using msg.value with delegate call has no meaning at all since the balance of contract already contains the value, you could use it to know how much was transferred, though

For reference: Call() is declared in the EVM with value parameter:

func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas uint64, value *uint256.Int) (ret []byte, leftOverGas uint64, err error) {

But DelegateCall() has the value parameter absent , because it is not needed anymore:

func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error) {

The msg.value is stored in a transaction context variable, so it will stay there until last instruction of transaction is executed

These functions are located in core/vm/evm.go file (of official go-ethereum sources) , if you need more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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