In this track: Smart contract security foundations
advanced · 4 MIN READ

ERC-20 return value differences

Integration code must handle actual token call conventions.

LET’S PICTURE IT

Two service desks can report failure through different response formats.

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.

Read the standard result

The ERC-20 interface includes boolean success results and requires callers to handle false. A non-reverting call is not automatically a true return value.

Recognize deployed differences

Some deployed tokens return no boolean data or have other nonstandard behavior. An integration should use a reviewed compatibility approach rather than inventing one from a single token test.

Separate transfer amount behavior

A compatible call wrapper does not automatically make fee-on-transfer, rebasing or callback behavior fit the application’s accounting assumptions.

Test the intended asset set

Use mocks for false, empty and reverting results, then assess each supported real asset’s documented behavior. A generic interface alone is insufficient.

Reason about the scenario

call outcome: success / failure
return payload: true / false / empty / malformed
asset behavior: separate accounting assumptions

Pseudocode or a simplified scenario for local reasoning. This is not a production contract or a completed security review.

QUICK CHECK · NO PRESSURE

Does non-reverting execution always imply an ERC-20 true result?

Your progress stays in this browser.
Keep exploring the original referencedocs.openzeppelin.com ↗

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