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
    May 30 '20 at 11:13
  • yes,that is what I want。 May 31 '20 at 5:17
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, privacy policy and cookie policy

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