I am trying to understand how errors, specially custom-errors, are being handled when Ethereum transactions are reverted.

From what I know, both successful and reverted transactions are mined into the blocks, and both also emit transaction receipts which are stored forever on the blockchain. These reverted transaction receipts don't store any information associated with the failure reason.

How does Etherscan, or the other block explorers, deduce the revert reason?

Do they simulate the transactions using a node, e.g., geth?

2 Answers 2


You can take a look at how does custom-errors are being handled when Ethereum transaction fails with this example:


Etherscan can deduce the revert reasons based on the explanation on the reasons:


Failed transactions on Etherscan


One solution I found to catch the custom error was to use callStatic in the following away:

async function customErrorWithNumber() {
  try {
    const tx = await contract.callStatic.customErrorWithNumber(666, {
      blockTag: <blockNumber>,
  } catch (error) {
    console.log("caught error:\n", error);

In that case the error retrieved would have the form:

  reason: null,
  method: 'customErrorWithNumber(uint256)',
  data: '0xc5d83cde0000000000000000000000000000000000000000000000000000000000000000',
  errorArgs: [ BigNumber { _hex: '0x00', _isBigNumber: true } ],
  errorName: 'InvalidNumber',
  errorSignature: 'InvalidNumber(uint256)',
  address: '0x6826E8a44c1aeceB84de44Ec13FfEEc9e2e67B67',
  args: [ 666 ],
  transaction: {
    data: '0xe129f95c000000000000000000000000000000000000000000000000000000000000029a',
    to: '0x6826E8a44c1aeceB84de44Ec13FfEEc9e2e67B67'

In this article I have written with more details how to do it.

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.