2

I found an error message, 'invalid opcode 0xfd'. What does this mean?

I googled, and found just one result here.

Quote: "I the invalid opcode 0xfd is never hit (Some compilers encode safety properties using 0xfd)"

1 Answer 1

5

0xfd is the REVERT opcode as described in the EIP140.

Things to know:

  1. REVERT is intended as a "soft throw" that does not consume all the remaining gas. It can also return some data, which could be useful for debugging and user feedback.

  2. It is not yet implemented by the EVM; it will be implemented by the first Metropolis fork. This is why it is currently reported as "invalid opcode" when the EVM encounters it.

  3. Nonetheless, the Solidity compiler already implements and generates REVERTs via the require() statement. It is recommended to be used for user input validation. Since the opcode is not yet available, it currently acts just like the old throw, but after Metropolis it will implement the new functionality.

2
  • So if you use require() before metropolis fork, it displays 'VM returned with error err="invalid opcode 0xfd"'. But it's worked as expected, so it's not an error. Am I right? Commented Aug 29, 2017 at 10:57
  • It depends what you mean by "not an error". Something went wrong if your require failed: now it results in the invalid opcode exception; in future it will revert more nicely. In either case the code execution terminates. Commented Aug 29, 2017 at 11:21

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.