2

I can see the error message on Etherscan.

But I can't find it in getTransactionRecept().

Is there any special settings that I need set in my Genesis.json before I can see it?

2

Yes you can! I made an NPM package to help with this: eth-revert-reason. You can use that package to get the revert reason from a transaction with just the hash!


It is hard to decode the revert reason in a generalized manner. Many different factors, such as web3.js vs. ethers, Geth vs. Parity, etc. will result in different results for all the answers posted here. Some issues are:

  1. For a Kovan transaction, you need a custom provider that exposes Parity trace methods.
  2. Transactions may result in different messages depending on the context of the block they are called from. Because of this, you may need to be running a full-archival node in order to retrieve the correct error message.

In a happy-path case, the code to retrieve the revert reason is:

const provider = customProvider || ethers.getDefaultProvider(network)
const tx = await provider.getTransaction(txHash)
const code = await provider.call(tx)

While the code to generate the revert reason in the normal case is simple, the non-happy-path cases are surprisingly difficult to handle, however this package attempts to appease this.

2
  • 1
    So your package would return the same revert-message on a given transaction, regardless of which node (Geth, Parity, Ganache for local networks) or facade (infura, alchemy, etherscan) is used in order to interact with the network? – goodvibration Aug 19 '20 at 20:13
  • In it's current form, no. However, it is on the roadmap. github.com/authereum/eth-revert-reason#future-work – Shane Fontaine Aug 19 '20 at 21:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.