Skip to the article
Onchain Brief

News from across crypto

Reverted vs out of gas: know what you paid

Reverted vs out of gas transactions both cost gas: a revert charges for gas used, while an out-of-gas failure spends the full gas limit. Here’s how to tell.

The Onchain Brief Editors3 min read
Reverted vs out of gas: know what you paid

A failed Ethereum transaction can still cost a fee: a revert charges for the gas used before execution stopped, while an out-of-gas failure consumes the full gas limit. Validators did the work before the failure, and the fee pays for that computation.

The wallet’s “failed” label does not tell you how much gas was spent. Look at the transaction receipt’s status, gas used, and effective gas price to find out what happened.

Reverted or out of gas: what happened?

A reverted transaction stopped at a failed check, such as a swap’s slippage limit. Slippage is the price movement a swap allows before it cancels. The tell-tale sign is a failed status with gas used below the limit. The REVERT opcode, introduced by EIP-140, rolls back the transaction’s state changes and returns the unused gas. You still pay for the gas that ran.

A private transaction route can help avoid paying for a call that would revert. Flashbots is an Ethereum research and infrastructure organization, and Flashbots Protect is one service that keeps transactions expected to revert from being included. The private transactions ethereum approach is useful context for how that can work.

An out-of-gas failure means execution hit the transaction’s gas limit before it could finish. Its tell-tale sign is gas used matching the full limit. This can happen when the limit was set too low for the contract’s work. The state changes are rolled back, but the gas is still spent.

  • Revert: some gas used; unused gas returned.
  • Out of gas: the full gas limit used.

Both failures cost gas because the network processed the transaction before it failed. Under EIP-1559, the fee is gas used multiplied by the effective gas price. The base-fee portion is burned even for a failed transaction.

How to avoid another failed fee

For a revert, read the failure message and address the failed check before retrying. A swap may need a refreshed quote or a slippage setting that fits current market movement. Simply raising the gas limit will not increase the fee for the same reverting call: the unused gas is returned.

For an out-of-gas failure, check the wallet’s estimate and the transaction details before retrying. A higher limit can give the call room to finish, but setting it too low risks spending the entire limit again. Unlike a revert, an out-of-gas failure has no unused gas to return.

If neither pattern fits, compare the receipt’s gas used with its gas limit, then multiply gas used by the effective gas price to understand the fee. If there is no included transaction receipt, check whether the wallet is showing a pending or rejected submission instead: a transaction that never made it on-chain did not use execution gas.