In my App.js I have called the smart contract function and the require statement in the function is not satisfied, so how do I get the message of that require statement in my App.js?

2 Answers 2


Web3 1.2.5 supports the revert messages now, activated by setting web3.eth.handleRevert = true. You can use TestContract.methods.myMethod(myParam).call().catch(console.log) to receive the message without sending the transaction.

See https://soliditydeveloper.com/web3-1-2-5-revert-reason-strings for more details.

  • Thank you! This has been long in making. Commented Apr 14, 2020 at 17:09

You should probably ask yourself how else would the transaction revert without being executed.

It doesn't change any of the state variables which the contract function is designated to.

But it is still executed to the point where the require statement is rejected, and a REVERT opcode along with the error-message is sent from the node back to your application.

If you're communicating with the node via web3.js, then the latter typically throws an exception with an error-message which starts with "VM Exception while processing transaction: revert" and ends with the error-message of the require statement.

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.