Transaction Error Handling – How Does Transaction Error Catching Work?

custom-errorserrorreceipts

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?

Best Answer

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

https://medium.com/coinmonks/solidity-revert-with-custom-error-explained-with-example-d9dff8937ef4

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

https://info.etherscan.com/reason-for-failed-transaction/

Failed transactions on Etherscan

Related Topic