---
eip: 3978
label: EIP-3978
title: Gas refunds on reverts
status: Stagnant
type: Standards Track
category: Core
created: 2021-09-16
requires: 2929
official: https://eips.ethereum.org/EIPS/eip-3978
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3978.md
canonical: https://eips.huatuo.xyz/eip-3978/
lang: en
tldr: Proposed that when a call reverts, users get back the gas paid for state changes that were thrown away (storage writes, logs, contract creation), keeping only the cost of access.
tags: [gas, refunds, revert, evm, core]
---

# EIP-3978: Gas refunds on reverts

> Reprice reverted SSTORE/CREATE/SELFDESTRUCT/LOGX operations gas via gas refund mechanism

**TL;DR:** Proposed that when a call reverts, users get back the gas paid for state changes that were thrown away (storage writes, logs, contract creation), keeping only the cost of access.

## What problem does it solve?

When a transaction or a sub-call reverts, every state change it made is discarded. But the gas for those changes has already been charged as if they had persisted: a reverted `SSTORE` still costs the full write price, a reverted `CREATE` still costs 32,000 gas, and so on.

Worse, a revert also wipes out any gas refund the call had accumulated. The authors point out that it can be cheaper to undo work manually (for example, transfer tokens back) than to revert, just to keep the refund. That is the opposite of what a well-designed fee schedule should encourage.

## How it works

Each call frame tracks a new counter, `revert_gas_refund`, starting at 0. Whenever one of these state-modifying operations runs, the counter grows by the operation's cost minus the warm-read cost (`WARM_STORAGE_READ_COST`, 100 gas, from [EIP-2929](/eip-2929/)):

- `SSTORE`
- `LOG0` to `LOG4`
- `CALL` (the value-transfer and new-account surcharges)
- `CREATE`, `CREATE2`
- `SELFDESTRUCT`

If the frame reverts, the existing behaviour (dropping that frame's normal refund) still happens, and then `revert_gas_refund` is credited to the transaction's refund. The net effect is that a reverted modification costs roughly what a read costs, about 100 gas, instead of its full price.

The motivation also suggests charging `CREATE`/`CREATE2`'s 32,000 gas only when the returned bytecode is non-empty, though the specification section does not define this.

## Sample code

Pseudocode of the accounting, adapted from the spec:

```javascript
// on each SSTORE / LOGx / CALL / CREATE / CREATE2 / SELFDESTRUCT
call.revert_gas_refund += operation.gas - WARM_STORAGE_READ_COST; // 100

// when a call frame finishes
if (call.reverted) {
  tx.gas_refund -= call.gas_refund;        // existing behaviour
  tx.gas_refund += call.revert_gas_refund; // new: refund discarded modifications
}
```

## Things to know

- Status: **Stagnant**. It was not adopted; reverted operations are still charged in full on Ethereum.
- Test cases, reference implementation and security considerations were left as "TBD" in the spec.
- Refunds on Ethereum are capped as a fraction of gas used ([EIP-3529](/eip-3529/) tightened this and removed most refund sources), so any revert refund would be subject to that cap as written.
- Related history: [EIP-3298](/eip-3298/) proposed removing refunds; EIP-3529 is what shipped in London.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-3978
