0

I have a ReactJS project that can communicate with my smart contract. However, in my smart contract I have used the Require function to check for certain conditions before proceeding to execute down stream code. However, I do not know how to access the error messages in the event that certain conditions are not met.

For example:

 bool public isRed = false;
 require(isRed, "The state is not red");

How would I be able to access the "The state is not red" from the front end I am currently using Alchemy web3 to communicate with the blockchain?

johnDoe
  • 709
  • 11
  • 29
  • Does this answer your question? [How to properly use revert reason in web3.js to show meaningful error message in UI](https://stackoverflow.com/questions/66878031/how-to-properly-use-revert-reason-in-web3-js-to-show-meaningful-error-message-in) – Petr Hejda Nov 12 '21 at 08:35
  • I know in ethers.js, do you think it is useful to you?! – Ahmad Gorji Nov 12 '21 at 09:07

0 Answers0