A failed transaction still costs money. The fee buys computation, not an outcome: the network charges for the work of executing your instructions, and a revert is a legitimate result that still consumed that work. Nothing is refunded because nothing went wrong from the chain’s point of view.

That single fact explains most of the confusion around failed swaps, stuck transfers and “why did I pay twice”. What follows breaks the cost into its parts, shows how to compute it from a receipt, and covers the failure mode that hurts most — the nonce gap, where one bad transaction blocks every later one from the same wallet.
- You are billed for gas used, not gas estimated. A revert consumes everything up to the point of failure and returns the rest, if the transaction did not run out of gas entirely.
- Out of gas is worse than a revert. The transaction burns the full limit you set, because the failure is the exhaustion itself.
- A nonce gap costs more than gas. It freezes every subsequent transaction from that address until it is filled or replaced.
- Most failures are cheaper to prevent than to repeat. A simulation before signing costs nothing; a retry costs a full fee every time.
Gas pays for execution, not for success
Every opcode a contract executes has a price in gas, and the total is metered as the transaction runs. When a require fails or a contract calls revert, the EVM undoes the state changes but does not undo the metering. The work was performed, the nodes verified it, and the block that includes your failed transaction is built and propagated like any other.
This is deliberate. If failed execution were free, anyone could submit transactions designed to consume validator time at no cost. Charging for failure is what makes spam expensive, and the same rule that protects the chain is the one that bills you for a swap that never happened.
What the receipt tells you
A mined transaction returns a receipt with a status field. A value of 1 means success; 0 means the transaction reverted but was still included in a block. The receipt also carries gasUsed and, on post-London chains, effectiveGasPrice. Those two numbers are the whole bill for the execution portion.
A transaction that never reaches a block is a different case. If it is rejected by the node, dropped from the mempool, or replaced before inclusion, no gas is charged at all — because no execution happened. The cost there is time and price movement, not fees.
Why out of gas is the expensive version
When you set a gas limit of 200,000 and the transaction needs 260,000, execution stops at the limit and the entire 200,000 is consumed. There is no partial result and no refund, because the refund is calculated from unused gas and there is none. The same logic applies when a loop runs longer than expected or a contract makes an external call that returns more data than the estimate assumed.
Estimates are usually generous enough to avoid this, which is why out-of-gas failures cluster around a specific kind of change: state that shifted between the estimate and the execution, such as a pool’s liquidity or a contract’s storage layout. The estimate was correct for the block it was made against, not for the block that mined you.
The arithmetic of one failure
The execution cost of a failed transaction is gasUsed × effectiveGasPrice. On a rollup, add the L1 data component the receipt exposes, which pays for posting the transaction’s calldata to the parent chain. Both terms are visible before you decide whether to retry.
Reading the numbers off a receipt
Block explorers show these fields on the transaction page, usually under a “Gas” or “Transaction fee” panel. The figure labelled “Transaction fee” is normally already the product, and it is the number you want. Where the explorer reports a separate L1 fee, the total is the sum of the two, not the larger one.
One caution on pre-London habits: gasPrice and effectiveGasPrice are not the same field. The first is what you offered, capped by maxFeePerGas; the second is what you were actually charged after the base fee was burned. Multiplying by the wrong one inflates or deflates the result by the size of the tip.
A worked example
The numbers below are a hypothetical, chosen so the structure is visible. Substitute your own receipt values and the shape holds.
- Open the failed transaction and note
gasUsed: say 187,000. - Note
effectiveGasPrice: say 24 gwei, which is 0.000000024 ETH per gas. - Multiply: 187,000 × 0.000000024 = 0.004488 ETH.
- Convert at your reference rate. At $3,000 per ETH, that is $13.46.
- Add the L1 data fee if the chain charges one: say 0.00021 ETH, or $0.63.
- Total cost of the failure: $14.09, for a swap that produced nothing.
Two things follow. A failure on a busy L1 costs real money, the same order as the trade fee on a mid-sized order. And the cost is entirely a function of gas used and gas price, both visible before you sign, which makes a likely revert a transaction you can decline to send.
Nonce gaps: the failure that blocks everything behind it
Every account has a nonce, and every transaction from that account must carry the next number in sequence. If transaction 41 is stuck, transaction 42 cannot be mined, no matter how much you pay for it. Miners and validators will not include 42 while 41 is missing, because doing so would break the ordering the account’s state depends on.
This turns a single bad transaction into a queue. The classic cause is a transaction priced below the current base fee: it sits in the mempool, valid but uneconomical, while everything behind it waits. The visible symptom is a wallet showing “pending” on transactions you sent minutes or hours ago, with later ones apparently ignored.
Why later transactions cannot overtake
The rule is enforced by every node, not by policy. A block that included nonce 42 without 41 would produce a state that other nodes reject, so no rational builder attempts it. The gap has to be closed at the gap: the stuck transaction must be mined, replaced with one at the same nonce, or cancelled with an empty transaction at that nonce.
Replacing or cancelling
Replacement means resubmitting at the same nonce with a higher fee. Most node implementations require a minimum bump, commonly around 10% over the original, though the exact threshold is a node policy rather than a protocol rule. Cancellation is the same mechanism with a zero-value transfer to your own address: it fills the nonce without doing anything else.
The cost of either route is two fees for one outcome. You pay the replacement in full, and you often pay the original too if it eventually gets mined after your replacement fails to propagate. Add the capital that was frozen for the duration and the price you could not act on, and the nonce gap is usually the most expensive failure on the list — not because any single fee is large, but because it stops you from doing anything at all.
Five failure modes and what each one takes
The table separates what is actually lost in each case, because two of these cost no gas at all and one costs gas without producing a revert.
| Failure type | What you actually lose | Avoidable |
|---|---|---|
| Out of gas | The entire gas limit, with no state change and no refund | Mostly — raise the limit when state is moving, or simulate first |
| Revert (require, custom error) | Gas consumed up to the revert, plus any approval already paid | Often — the revert reason usually states the condition |
| Nonce gap | Frozen queue, a second full fee to replace or cancel, and the delay itself | Yes — do not leave an underpriced transaction pending |
| Slippage guard trip | A full swap’s gas for zero output; the price moved against you before inclusion | Partly — wider tolerance trades cost for certainty |
| Dropped and replaced | No gas if never included; the time and the price movement are the loss | Yes — check the mempool before assuming it is stuck |
The slippage row deserves its own note. A router revert because minAmountOut was not met is a success for the guard and a loss for you: the contract correctly refused a bad fill, and you still paid for the check. Widening the tolerance converts some of those failures into worse fills, which is not obviously cheaper. The trade-off is between paying gas for nothing and paying spread for something.
Failures you did not cause: MEV and the slippage guard
A sandwich attack is the clearest case of a failure that costs you money without any mistake on your part. A searcher sees your pending swap, buys ahead of it to move the price, lets your transaction fill at the worse price, then sells behind it. If your slippage tolerance is tight, your transaction reverts instead — and the searcher keeps the difference while you keep the gas bill.
Either outcome is profitable for the attacker: a fill at a worse price, or a revert that costs you a fee. The guard did its job by capping the damage, but the cap is not zero, because the attempt was already paid for.
How one sandwich produces two failures
The first failure is the revert itself. The second is the retry, which is submitted into the same conditions and is often sandwiched again. Users who retry three times in a fast market can pay three full fees and still end up with nothing, which is why the visible cost of MEV is usually higher than the extracted value on any single trade.
Private submission as a partial fix
Sending through a private relay or an RPC with MEV protection keeps your transaction out of the public mempool until it is included, which removes the observation step a sandwich depends on. It does not remove reversion risk from genuine price movement, and it does not make a bad price a good one. It only removes the audience.
The compounding cost of retrying
Retrying the same transaction unchanged is the most common expensive habit in on-chain trading. Each attempt is a fresh fee, and the conditions that caused the first failure are usually still present. Three attempts at 200,000 gas and 24 gwei is roughly 0.0144 ETH — about $43 at $3,000 — spent to learn nothing.
The arithmetic gets worse when the retry also raises the fee to jump the queue. A 20% bump on each attempt means the third try costs more than the first, and the total is well above three times a single failure. Meanwhile the price you were trying to act on has moved, so the trade you eventually get is not the trade you wanted.
What to change before the second attempt
Something has to differ, or the second attempt is a donation. Either the gas limit goes up, or the slippage tolerance widens deliberately, or the route changes, or the timing changes. Reading the revert reason is the cheapest step available: most contracts return a string or a custom error that names the exact condition, and explorers decode it for you.
When to stop
If two attempts fail for the same decoded reason, the constraint is not gas and not luck. It is a state condition — an allowance, a balance, a paused contract, a pool that no longer has the liquidity you assumed. A third attempt priced higher will fail faster and cost more.
A failed transaction is not a refund waiting to happen. It is a purchase of computation at the market rate, and the only part you control is whether you buy it once or five times.
A checklist before you sign
- Simulate. Most wallets and RPCs will run the transaction against current state and return the revert reason for free.
- Check the gas limit against the estimate. A limit equal to the estimate has no margin for a state shift.
- Confirm the nonce has no gap. If an earlier transaction is pending, everything behind it is queued, not lost.
- Set slippage deliberately. The default is a guess about a market you have not looked at.
- Price the attempt before you make it. Gas used times effective gas price is a number you can compute in advance.
- Decide the retry rule now. One retry with a changed parameter, then stop and read the error.
None of this makes failure free. It makes failure rare, and it makes the ones that remain cheap enough to shrug at. The mechanics behind the slippage row are covered in more detail in Slippage: The Cost Between the Quote and the Fill, and the choice between paying for certainty and paying for speed is the subject of Limit Orders vs Market Orders: What Speed Costs. If your failure came from a fill that walked too deep into the book, the cause is depth rather than gas, which Order Book Depth: Why Your Fill Is Worse Than the Price sets out in full.
0 comments
No comments yet — ask a question and we will answer it here.