In this track: Gas and execution fees
intermediate · 3 MIN READ

Why a revert still costs gas

Rolling back state does not erase computation already performed.

LET’S PICTURE IT

An office can process an application and reject it after checking its details. The work occurred even though the requested change was not approved.

SEE IT FOR YOURSELF
Calculate and split a manual execution feeStep 1 / 4
Calculate and split a manual execution feeGas used21,000A resource quantityGas used and gas limit are different quantitiesBase10 GweiEffective tip2 GweiTotal rate12 Gwei / gasAssumed total cap: 20 Gwei; no live prices are fetchedWork × rate21,000 × 12252,000 GweiExecution fee0.000252 ETHExact unit conversionThis calculation excludes blob and layer 2 data feesBase component0.00021 ETHBurned by protocolPriority component0.000042 ETHTo fee recipientComponents sum to the supplied 0.000252 ETH example

This example supplies twenty-one thousand gas used. It is a simple teaching input, not a live estimate of a contract call.

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

Revert changes the state outcome

A reverted call rolls back its state changes under execution rules. That gives atomicity to the affected operation; it does not travel backward and remove the computational steps that were needed to reach the failure.

Gas records that work

The transaction can still incur execution fees for consumed resources. An explicit REVERT can return unused gas to its caller context, which differs from claiming all spent gas is refunded.

A receipt reports the final context

For a top-level failed transaction, the receipt status indicates failure and gas fields describe accounting. A failed inner call caught by an outer contract may occur within a top-level successful transaction.

Error bytes are an aid, not a full trace

A readable error can point to a failed condition, but it does not explain every gas-consuming step. Use supplied revert data in the decoder while recognizing the missing code and state context.

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

Does REVERT erase the cost of work already executed?

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.