1

I am trying to understand the revert opcode and how it works . I understood that it will stop the execution of current context and return 0 to the calling context. It seems it also takes in 2 arguments according to evm.codes. Can someone help me understand what the two arguments does? enter image description here

1 Answer 1

2

offset is the starting position of the desired return data in memory and size is the size of the desired return data in memory. Offset and size are used to designate where the return data starts (offset) and ends (offset + size) in memory.

See: https://medium.com/@jtriley15/yul-vs-solidity-contract-comparison-2b6d9e9dc833

2
  • Thank you will check the article but I have a doubt. Why do we need to return a particular data from the memory? If it comes to revert then it is because there is some error in the smart contract and we have to return 0 only right? I know my question here is bit silly but would love to understand if there are any specific cases where returning data from the memory is useful? Nov 6, 2022 at 7:10
  • if there is an error, 0 is returned on the stack and the returned data is served as an error message to the caller, and doing so, it will not consume all the remaining gas. See: eips.ethereum.org/EIPS/eip-140 Nov 6, 2022 at 17:36

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.