2

Suppose I have two solidity functions:

function funcA()public{}

And

function funcB()public payable{}

What's the difference between their bytecode? if I call the funcA with some ether in the transaction, it will revert, and what happens in bytecode?

2
  • Can you clarify your question please? are you trying to recognize payable and non-payable function by looking at the bytecode?
    – Masoud jt
    Commented May 30, 2020 at 11:13
  • yes,that is what I want。 Commented May 31, 2020 at 5:17

1 Answer 1

1

At the beginning a non-payable function will execute CALLVALUE and revert if it returns a non-zero value.

For example:

Assembly                 | Pseudocode
---------------------------------------------
  CALLVALUE              |
  DUP1                   |
  ISZERO                 |  if (msg.value == 0)
  PUSH2 label            |
  JUMPI                  |    goto label
  PUSH1 00               |
  DUP1                   |
  REVERT                 |  revert("")

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.