{"eip":3298,"title":"Remove storage-clear refund and refund cap","description":"Removes the SSTORE storage-clearing refund and the transaction refund cap, leaving only net-metered same-transaction write reversals","authors":["Vitalik Buterin (@vbuterin)","Martin Swende (@holiman)","Jochem Brouwer (@jochem-brouwer)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2021-02-26","requires":[2780,3529,7778,8037,8038],"discussionsTo":"https://ethereum-magicians.org/t/eip-3298-removal-of-refunds/5430","repo":"EIPs","label":"EIP-3298","officialUrl":"https://eips.ethereum.org/EIPS/eip-3298","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3298.md","url":"https://eips.huatuo.xyz/eip-3298/","tldr":{"en":"Draft that removes the SSTORE storage-clearing refund and the 20% refund cap, keeping only the refund for undoing a write within the same transaction.","ja":"SSTORE のストレージクリア払い戻しと 20% の払い戻し上限を廃止し、同一トランザクション内で書き込みを元に戻した場合の払い戻しだけを残す Draft。","ko":"SSTORE의 스토리지 비우기 환불과 20% 환불 상한을 없애고, 같은 트랜잭션 안에서 쓰기를 되돌렸을 때의 환불만 남기는 초안.","zh":"取消 SSTORE 清除存储的退款以及 20% 退款上限，只保留在同一笔交易内撤销写入时的退款的草案。"},"tags":["gas","refunds","sstore","evm","core"],"explainers":{"en":{"lang":"en","tldr":"Draft that removes the SSTORE storage-clearing refund and the 20% refund cap, keeping only the refund for undoing a write within the same transaction.","tags":["gas","refunds","sstore","evm","core"],"related":[3529,8038,8037,7778,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-3298/","markdown":"## What problem does it solve?\n\nSince Frontier, Ethereum has refunded gas when a contract clears a storage slot, to reward \"state hygiene\". In practice the incentive never worked well, and it was abused (gas tokens) until [EIP-3529](/eip-3529/) cut refunds and capped them at 20% of gas used.\n\nToday, state growth is being addressed by charging for state *creation* directly ([EIP-8037](/eip-8037/)), not by rebates for cleanup. Meanwhile the refund counter and its cap complicate gas settlement, interacting with the calldata floor of [EIP-7623](/eip-7623/) and the separate gas dimensions of EIP-8037. This EIP removes the last cross-transaction refund and the cap that exists mainly to contain it.\n\n## How it works\n\nThe spec is written as a change on top of [EIP-8037](/eip-8037/) and [EIP-8038](/eip-8038/), and assumes those plus [EIP-2780](/eip-2780/) and [EIP-7778](/eip-7778/) are active.\n\n**Removed:** `STORAGE_CLEAR_REFUND` (11,616 gas under EIP-8038) and both rules that use it: the refund for clearing a slot whose original value was non-zero, and the reversal of that refund if the slot is restored.\n\n**Kept:** one rule. If an `SSTORE` sets a slot back to its **original** value (its value at the start of the transaction) and that differs from its current value, `STORAGE_WRITE` is refunded. This is net metering: a round trip like `x → y → x` pays only access costs, not for a write that was undone.\n\n**Cap removed:** the transaction refund is simply the refund counter.\n\n```python\ntx_gas_used_before_refund = tx.gas - gas_left - state_gas_reservoir\ntx_gas_used_after_refund  = tx_gas_used_before_refund - refund_counter   # no // 5 cap\ntx_gas_used = max(tx_gas_used_after_refund, calldata_floor_gas_cost)\n```\n\nThe cap is safe to drop because the remaining refund is self-bounded: each refund reverses exactly one `STORAGE_WRITE` already charged in the same transaction, and refunds from reverted frames are discarded. Block-level gas accounting already ignores refunds under EIP-7778, so worst-case block resource use does not change.\n\n## Sample code\n\nRefund counter for one warm slot under this EIP (`W` = `STORAGE_WRITE`), from the spec:\n\n| Sequence (original first) | Charged | Refunded | Net write cost |\n| --- | --- | --- | --- |\n| `0 → x` | `W` | 0 | `W` |\n| `0 → x → 0` | `W` | `W` | 0 |\n| `x → 0` | `W` | 0 | `W` (no clearing refund) |\n| `x → y → x` | `W` | `W` | 0 |\n| `x → y → x → z` | `W`, `W` | `W` | `W` |\n\nA pattern that stays cheap, a re-entrancy lock that ends where it started:\n\n```solidity\nuint256 private locked = 1;\nmodifier nonReentrant() {\n    require(locked == 1);\n    locked = 2;   // write: charged\n    _;\n    locked = 1;   // back to original: write refunded\n}\n```\n\n## Things to know\n\n- **Status: Draft.** It depends on several proposals that are themselves not final, and the spec describes it as targeting the fork *after* the one that ships EIP-8038.\n- Contracts that clear storage to collect refunds (batch cleanup, gas-token-style tricks) would pay more: clearing a slot would no longer return gas.\n- Gas estimators and wallets would need to drop clearing-refund and refund-cap logic.\n- The spec warns that any future refund not backed by a same-transaction charge must bring back a cap or an equivalent bound.\n- For temporary flags like locks, transient storage ([EIP-1153](/eip-1153/)) avoids persistent writes entirely.\n"},"ja":{"lang":"ja","tldr":"SSTORE のストレージクリア払い戻しと 20% の払い戻し上限を廃止し、同一トランザクション内で書き込みを元に戻した場合の払い戻しだけを残す Draft。","tags":["gas","refunds","sstore","evm","core"],"related":[3529,8038,8037,7778,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-3298/","markdown":"## 何を解決するのか\n\nFrontier 以来、Ethereum はコントラクトがストレージスロットをクリアするとガスを払い戻し、「状態の衛生管理」に報いてきました。実際にはこのインセンティブはうまく機能せず、[EIP-3529](/eip-3529/) が払い戻しを削減して使用ガスの 20% を上限とするまで、悪用（ガストークン）されていました。\n\n現在、状態の肥大化には、クリーンアップへの払い戻しではなく、状態の*作成*に直接課金する形（[EIP-8037](/eip-8037/)）で対処が進められています。一方で、払い戻しカウンターとその上限はガス精算を複雑にし、[EIP-7623](/eip-7623/) の calldata フロアや EIP-8037 の個別のガス次元と相互作用します。この EIP は、トランザクションをまたぐ最後の払い戻しと、主にそれを抑えるために存在する上限を取り除きます。\n\n## 仕組み\n\n仕様は [EIP-8037](/eip-8037/) と [EIP-8038](/eip-8038/) の上に載る変更として書かれており、それらに加えて [EIP-2780](/eip-2780/) と [EIP-7778](/eip-7778/) が有効であることを前提としています。\n\n**削除されるもの:** `STORAGE_CLEAR_REFUND`（EIP-8038 では 11,616 gas）と、それを使う 2 つのルール、すなわち元の値が 0 以外だったスロットをクリアした際の払い戻しと、スロットが元に戻された場合のその払い戻しの取り消しです。\n\n**残るもの:** 1 つのルール。`SSTORE` がスロットを**元の**値（トランザクション開始時の値）に戻し、それが現在の値と異なる場合、`STORAGE_WRITE` が払い戻されます。これはネットメータリングです。`x → y → x` のような往復は、取り消された書き込み分ではなく、アクセスコストだけを支払います。\n\n**上限の廃止:** トランザクションの払い戻しは、単に払い戻しカウンターの値になります。\n\n```python\ntx_gas_used_before_refund = tx.gas - gas_left - state_gas_reservoir\ntx_gas_used_after_refund  = tx_gas_used_before_refund - refund_counter   # no // 5 cap\ntx_gas_used = max(tx_gas_used_after_refund, calldata_floor_gas_cost)\n```\n\n残る払い戻しは自己限定的なので、上限は安全に外せます。各払い戻しは、同じトランザクション内ですでに課金された `STORAGE_WRITE` をちょうど 1 つ取り消すもので、revert されたフレームからの払い戻しは破棄されます。ブロックレベルのガス会計は EIP-7778 によってすでに払い戻しを無視しているため、最悪時のブロックのリソース使用量は変わりません。\n\n## サンプルコード\n\nこの EIP における 1 つの warm なスロットの払い戻しカウンター（`W` = `STORAGE_WRITE`）。仕様より:\n\n| シーケンス（最初が元の値） | 課金 | 払い戻し | 書き込みの正味コスト |\n| --- | --- | --- | --- |\n| `0 → x` | `W` | 0 | `W` |\n| `0 → x → 0` | `W` | `W` | 0 |\n| `x → 0` | `W` | 0 | `W`（クリア払い戻しなし） |\n| `x → y → x` | `W` | `W` | 0 |\n| `x → y → x → z` | `W`, `W` | `W` | `W` |\n\n安価なままのパターン。始まりと同じ状態で終わる再入ロック:\n\n```solidity\nuint256 private locked = 1;\nmodifier nonReentrant() {\n    require(locked == 1);\n    locked = 2;   // write: charged\n    _;\n    locked = 1;   // back to original: write refunded\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** それ自体がまだ final ではない複数の提案に依存しており、仕様は、EIP-8038 を搭載するフォークの*次の*フォークを対象としていると説明しています。\n- 払い戻しを得るためにストレージをクリアするコントラクト（一括クリーンアップ、ガストークン風のトリック）は、より多く支払うことになります。スロットをクリアしてもガスが戻らなくなるためです。\n- ガス見積もりツールやウォレットは、クリア払い戻しと払い戻し上限のロジックを外す必要があります。\n- 仕様は、同一トランザクション内の課金に裏づけられていない将来の払い戻しは、上限か同等の制限を復活させなければならないと警告しています。\n- ロックのような一時的なフラグには、一時ストレージ（[EIP-1153](/eip-1153/)）を使うと、永続的な書き込みを完全に避けられます。\n"},"ko":{"lang":"ko","tldr":"SSTORE의 스토리지 비우기 환불과 20% 환불 상한을 없애고, 같은 트랜잭션 안에서 쓰기를 되돌렸을 때의 환불만 남기는 초안.","tags":["gas","refunds","sstore","evm","core"],"related":[3529,8038,8037,7778,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-3298/","markdown":"## 어떤 문제를 해결하나요?\n\nFrontier 이후 이더리움은 컨트랙트가 스토리지 슬롯을 비우면 가스를 환불해 \"상태 위생\"에 보상해 왔습니다. 실제로 이 인센티브는 제대로 작동한 적이 없고, [EIP-3529](/eip-3529/)가 환불을 줄이고 사용 가스의 20%로 상한을 두기 전까지 악용(가스 토큰)되었습니다.\n\n오늘날 상태 증가는 정리에 대한 리베이트가 아니라 상태 *생성*에 직접 요금을 매기는 방식([EIP-8037](/eip-8037/))으로 다루고 있습니다. 한편 환불 카운터와 그 상한은 가스 정산을 복잡하게 하며, [EIP-7623](/eip-7623/)의 calldata 하한과 EIP-8037의 별도 가스 차원과 맞물립니다. 이 EIP는 트랜잭션에 걸친 마지막 환불과, 주로 그것을 억제하기 위해 존재하는 상한을 제거합니다.\n\n## 어떻게 동작하나요?\n\n스펙은 [EIP-8037](/eip-8037/)과 [EIP-8038](/eip-8038/) 위에 얹는 변경으로 쓰여 있으며, 이들과 함께 [EIP-2780](/eip-2780/) 및 [EIP-7778](/eip-7778/)이 활성화되어 있다고 가정합니다.\n\n**제거되는 것:** `STORAGE_CLEAR_REFUND`(EIP-8038에서는 11,616 gas)와 이를 사용하는 두 규칙, 즉 원래 값이 0이 아니었던 슬롯을 비울 때의 환불, 그리고 슬롯이 복원될 경우 그 환불의 취소입니다.\n\n**유지되는 것:** 규칙 하나. `SSTORE`가 슬롯을 **원래** 값(트랜잭션 시작 시점의 값)으로 되돌리고 그것이 현재 값과 다르면 `STORAGE_WRITE`가 환불됩니다. 이는 순 계량(net metering)입니다. `x → y → x` 같은 왕복은 되돌려진 쓰기 비용이 아니라 접근 비용만 냅니다.\n\n**상한 제거:** 트랜잭션 환불은 그냥 환불 카운터 값입니다.\n\n```python\ntx_gas_used_before_refund = tx.gas - gas_left - state_gas_reservoir\ntx_gas_used_after_refund  = tx_gas_used_before_refund - refund_counter   # no // 5 cap\ntx_gas_used = max(tx_gas_used_after_refund, calldata_floor_gas_cost)\n```\n\n남은 환불은 스스로 한도가 정해져 있으므로 상한을 버려도 안전합니다. 각 환불은 같은 트랜잭션에서 이미 부과된 `STORAGE_WRITE` 정확히 하나를 되돌리고, revert된 프레임의 환불은 폐기됩니다. 블록 수준 가스 회계는 EIP-7778에 따라 이미 환불을 무시하므로, 최악의 경우 블록 자원 사용량은 바뀌지 않습니다.\n\n## 샘플 코드\n\n이 EIP에서 warm 슬롯 하나의 환불 카운터(`W` = `STORAGE_WRITE`), 스펙에서 발췌:\n\n| 시퀀스(원래 값이 먼저) | 부과 | 환불 | 쓰기 순비용 |\n| --- | --- | --- | --- |\n| `0 → x` | `W` | 0 | `W` |\n| `0 → x → 0` | `W` | `W` | 0 |\n| `x → 0` | `W` | 0 | `W`(비우기 환불 없음) |\n| `x → y → x` | `W` | `W` | 0 |\n| `x → y → x → z` | `W`, `W` | `W` | `W` |\n\n계속 저렴한 패턴, 시작했던 값으로 끝나는 재진입 잠금:\n\n```solidity\nuint256 private locked = 1;\nmodifier nonReentrant() {\n    require(locked == 1);\n    locked = 2;   // write: charged\n    _;\n    locked = 1;   // back to original: write refunded\n}\n```\n\n## 알아둘 점\n\n- **상태: Draft.** 아직 최종이 아닌 여러 제안에 의존하며, 스펙은 EIP-8038을 싣는 포크의 *다음* 포크를 목표로 한다고 설명합니다.\n- 환불을 받으려고 스토리지를 비우는 컨트랙트(일괄 정리, 가스 토큰 방식의 기법)는 더 많이 내게 됩니다. 슬롯을 비워도 더는 가스가 돌아오지 않기 때문입니다.\n- 가스 추정기와 지갑은 비우기 환불과 환불 상한 로직을 없애야 합니다.\n- 스펙은 같은 트랜잭션의 부과로 뒷받침되지 않는 향후 환불은 상한이나 그에 준하는 제한을 되살려야 한다고 경고합니다.\n- 잠금 같은 임시 플래그에는 일시적 스토리지([EIP-1153](/eip-1153/))를 쓰면 영구 쓰기를 완전히 피할 수 있습니다.\n"},"zh":{"lang":"zh","tldr":"取消 SSTORE 清除存储的退款以及 20% 退款上限，只保留在同一笔交易内撤销写入时的退款的草案。","tags":["gas","refunds","sstore","evm","core"],"related":[3529,8038,8037,7778,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-3298/","markdown":"## 它解决什么问题？\n\n自 Frontier 以来，以太坊在合约清除存储槽时会退还 gas，以奖励「状态卫生」。实际上，这一激励从未很好地发挥作用，并且被滥用（gas token），直到 [EIP-3529](/eip-3529/) 削减了退款并将其上限设为已用 gas 的 20%。\n\n如今，状态膨胀的应对办法是直接对状态的*创建*收费（[EIP-8037](/eip-8037/)），而不是为清理提供返还。与此同时，退款计数器及其上限使 gas 结算变得复杂，并与 [EIP-7623](/eip-7623/) 的 calldata 下限以及 EIP-8037 的独立 gas 维度相互影响。该 EIP 取消了最后一项跨交易的退款，以及主要为遏制它而存在的上限。\n\n## 它如何运作\n\n该规范写作为叠加在 [EIP-8037](/eip-8037/) 和 [EIP-8038](/eip-8038/) 之上的变更，并假定它们以及 [EIP-2780](/eip-2780/) 和 [EIP-7778](/eip-7778/) 均已生效。\n\n**被移除的：** `STORAGE_CLEAR_REFUND`（在 EIP-8038 下为 11,616 gas），以及使用它的两条规则：清除原值非零的槽时的退款，以及槽被恢复时对该退款的撤销。\n\n**保留的：** 一条规则。如果某次 `SSTORE` 把槽设回其**原始**值（交易开始时的值），且该值不同于当前值，则退还 `STORAGE_WRITE`。这是净计量（net metering）：像 `x → y → x` 这样的往返只需支付访问成本，而不必为被撤销的写入付费。\n\n**取消上限：** 交易退款就是退款计数器本身。\n\n```python\ntx_gas_used_before_refund = tx.gas - gas_left - state_gas_reservoir\ntx_gas_used_after_refund  = tx_gas_used_before_refund - refund_counter   # no // 5 cap\ntx_gas_used = max(tx_gas_used_after_refund, calldata_floor_gas_cost)\n```\n\n取消上限是安全的，因为剩余的退款本身是有界的：每笔退款恰好撤销同一交易中已收取的一次 `STORAGE_WRITE`，并且被 revert 的调用帧中的退款会被丢弃。在 EIP-7778 下，区块层面的 gas 核算本来就忽略退款，因此最坏情况下的区块资源使用不会改变。\n\n## 示例代码\n\n根据规范，在该 EIP 下一个 warm 存储槽的退款计数器（`W` = `STORAGE_WRITE`）：\n\n| 序列（原值在前） | 收取 | 退还 | 写入净成本 |\n| --- | --- | --- | --- |\n| `0 → x` | `W` | 0 | `W` |\n| `0 → x → 0` | `W` | `W` | 0 |\n| `x → 0` | `W` | 0 | `W`（没有清除退款） |\n| `x → y → x` | `W` | `W` | 0 |\n| `x → y → x → z` | `W`, `W` | `W` | `W` |\n\n一个仍然保持便宜的模式：结束时回到起点的重入锁：\n\n```solidity\nuint256 private locked = 1;\nmodifier nonReentrant() {\n    require(locked == 1);\n    locked = 2;   // write: charged\n    _;\n    locked = 1;   // back to original: write refunded\n}\n```\n\n## 需要注意\n\n- **状态：Draft。** 它依赖于若干本身尚未最终确定的提案，并且规范说明它面向的是发布 EIP-8038 的那次分叉*之后*的分叉。\n- 为获得退款而清除存储的合约（批量清理、类似 gas token 的技巧）将付出更多：清除一个槽将不再退还 gas。\n- gas 估算器和钱包需要去掉清除退款和退款上限的逻辑。\n- 规范警告说，任何未来未由同一交易内的收费支撑的退款，都必须恢复上限或等效的约束。\n- 对于锁这类临时标志，使用瞬态存储（[EIP-1153](/eip-1153/)）可以完全避免持久写入。\n"}}}
