In this track: Connect everything together
advanced · 6 MIN READ

Decode standard and custom reverts

Choose a schema before interpreting failure bytes.

LET’S PICTURE IT

Different failure envelopes can carry a sentence, a code or typed fields.

SEE IT FOR YOURSELF
Follow a revert and decode its error dataStep 1 / 4
Follow a revert and decode its error dataRequested actionTransfer 100 raw unitsExample inputsAvailable balance40 raw unitsCheck the ruleA deliberately failing local scenario, not a live transactionCondition fails100 > 40Request rejectedRollbackNo successful transferConsumed gas still mattersTop-level failure and a caught nested failure have different contextsError selector0x08c379a04 bytesMessage tailNot enough tokensDynamic string encodingCustom errors and Panic use different selectors and schemasDecoded messageNot enough tokensA diagnostic clueFurther evidenceCaller and code pathRelevant stateError bytes can be constructed by code; decoding is not authentication

This fictional call requests a transfer of one hundred raw units while the relevant balance is forty.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

Recognize standard selectors

Error(string) and Panic(uint256) have different argument layouts. The first uses a dynamic tail, while the second uses a static numeric code.

Support an explicit custom declaration

A custom error needs its intended schema. Check selector and argument layout, then report the decoded names and values from that supplied declaration.

Handle empty and malformed data

Empty bytes contain no recoverable reason. Truncated or out-of-range encodings should produce a clear failure rather than fabricated empty values.

Preserve the evidence limits

Decoding does not authenticate the source or root cause. A parent may forward or replace bytes, and arbitrary code can construct matching payloads.

Your acceptance target

Error fixture:
0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f4e6f207469636b657473206c6566740000000000000000000000000000000000
Panic fixture:
0x4e487b710000000000000000000000000000000000000000000000000000000000000011
Custom fixture:
0xcf47918100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000005

Use only local examples and public sample addresses. State the assumptions and limits alongside the result.

TURN UNDERSTANDING INTO PRACTICEOpen the Revert decoder →
QUICK CHECK · NO PRESSURE

Does decoding authenticate the error’s author?

Your progress stays in this browser.
Keep exploring the original referenceSolidity documentation ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.