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?
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:
trace
methods.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.