0

I'm using Truffle/Drizzle/MetaMask and calling methods with send() and using .then() and .catch() and I rely on getting the error message send to .catch() e.g.

contract.methods['hello'](arg).send({
    from: drizzle.web3.eth.accounts.givenProvider.selectedAddress
})
.then(() =>

    // do good stuff

)
.catch((error) => {

    const message = error.message;

    // display a nice message to the user

}

to do things like tell the difference between the user cancelling the transaction and throwing "User denied transaction signature" vs my contract throwing a revert message (and which one) or a nonce mismatch so I can display a more helpful message in the UI.

However, error.message no longer gives me anything, all I get is Internal JSON-RPC error. no matter what the error.

Is this a change in MetaMask or Web3? It was working the last time I worked on my DApp a month ago.

How do I tell the difference between user cancel vs a revert message vs nonce mismatch, and how do I read the revert message thrown by the contract?

  • Perhaps you were testing against ganache previously. – Ismael Sep 14 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.