{"eip":3322,"title":"Account gas storage opcodes","description":"Allows contract accounts to store gas that can be transferred to the refund counter.","authors":["William Morriss (@wjmelements)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2020-03-04","discussionsTo":"https://ethereum-magicians.org/t/eip-3322-efficient-gas-storage/5470","repo":"EIPs","label":"EIP-3322","officialUrl":"https://eips.ethereum.org/EIPS/eip-3322","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3322.md","url":"https://eips.huatuo.xyz/eip-3322/","tldr":{"en":"A stagnant proposal for three opcodes that let a contract bank gas in an account-level counter and later release it into the transaction's refund counter, replacing storage-bloating gas tokens.","ja":"コントラクトがアカウント単位のカウンターにガスを貯め、後でそれをトランザクションの払い戻しカウンターに放出できる 3 つのオペコードを提案する、停滞中（Stagnant）の提案。ストレージを肥大化させるガストークンに代わるもの。","ko":"컨트랙트가 계정 단위 카운터에 gas를 저축했다가 나중에 트랜잭션의 환급 카운터로 방출할 수 있게 하는 세 가지 옵코드를 제안해, 스토리지를 부풀리는 gas 토큰을 대체하려는 정체(Stagnant) 상태의 제안.","zh":"一项停滞（Stagnant）的提案：用三个操作码让合约把 gas 存入账户级计数器，之后再释放到交易的退款计数器中，以取代会造成存储膨胀的 gas 代币。"},"tags":["evm","opcodes","gas","refunds","core"],"explainers":{"en":{"lang":"en","tldr":"A stagnant proposal for three opcodes that let a contract bank gas in an account-level counter and later release it into the transaction's refund counter, replacing storage-bloating gas tokens.","tags":["evm","opcodes","gas","refunds","core"],"related":[3529,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-3322/","markdown":"## What problem does it solve?\n\nIn 2020, gas tokens (GST2, CHI and similar) exploited the refund for clearing storage: you filled storage slots or created contracts when gas was cheap, then deleted them when gas was expensive and collected the refund. This shifted gas from quiet blocks to busy ones, which is arguably useful, but it did so by **writing useless data into state**, bloating every node's database.\n\nEIP-3322 proposed doing the same thing directly: let a contract store \"gas\" in a counter on its account, and release it later into the refund counter, with no junk storage involved.\n\n## How it works\n\nEvery contract account gains an unsigned **gas refund counter**, starting at zero. Three opcodes manage it:\n\n| Opcode | Byte | Stack | Gas | Effect |\n| --- | --- | --- | --- | --- |\n| `SELFGAS` | `0x49` | → counter | same as `SELFBALANCE` | Push this account's stored gas |\n| `USEGAS` | `0x4a` | amount → | 5000 | Move `min(amount, counter)` from the account into the transaction's refund counter |\n| `STOREGAS` | `0x4b` | amount → | 5000 + amount | Add `amount` to this account's counter |\n\nBecause released gas goes through the normal refund counter, it inherits the existing cap on refunds (at the time, 50 % of gas used), which limits how much it could stretch any one block. Gas costs were modelled on `SELFBALANCE` and `SSTORE`.\n\n## Sample code\n\nIllustrative assembly for \"bank now, spend later\" (the opcodes were never added to Ethereum, so this will not compile with current tools):\n\n```text\n; when gas is cheap: bank 100000 gas (costs 5000 + 100000)\nPUSH3 0x0186a0\nSTOREGAS          ; 0x4b\n\n; later, when gas is expensive: release up to 100000 into the refund counter\nPUSH3 0x0186a0\nUSEGAS            ; 0x4a  (costs 5000)\n\n; read the remaining balance\nSELFGAS           ; 0x49\n```\n\n## Things to know\n\n- Status is **Stagnant**; it was never scheduled for a fork.\n- The motivation largely disappeared with [EIP-3529](/eip-3529/) (London), which removed the `SELFDESTRUCT` refund and cut the storage-clearing refund and refund cap, making gas tokens unprofitable.\n- The spec's test-case table appears to use different opcode bytes from its own specification (for example `0x49` behaving like `USEGAS` and `0x4a` like `STOREGAS`), so the exact byte assignment is unclear.\n- Opcode bytes `0x49`–`0x4b` have since been used by other proposals (for example `BLOBHASH` is `0x49` and `BLOBBASEFEE` is `0x4a`), so these assignments are no longer available.\n"},"ja":{"lang":"ja","tldr":"コントラクトがアカウント単位のカウンターにガスを貯め、後でそれをトランザクションの払い戻しカウンターに放出できる 3 つのオペコードを提案する、停滞中（Stagnant）の提案。ストレージを肥大化させるガストークンに代わるもの。","tags":["evm","opcodes","gas","refunds","core"],"related":[3529,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-3322/","markdown":"## 何を解決するのか\n\n2020 年、ガストークン（GST2、CHI など）は、ストレージをクリアしたときの払い戻しを利用していました。ガスが安いときにストレージスロットを埋めたりコントラクトを作成したりし、ガスが高いときにそれらを削除して払い戻しを受け取るものです。これはガスを空いているブロックから混雑したブロックへ移すもので、その点では有用とも言えますが、**無意味なデータをステートに書き込む**ことで実現しており、すべてのノードのデータベースを肥大化させました。\n\nEIP-3322 は、同じことを直接行うことを提案しました。コントラクトがアカウント上のカウンターに「ガス」を貯め、後でそれを払い戻しカウンターに放出する仕組みで、無駄なストレージは一切使いません。\n\n## 仕組み\n\nすべてのコントラクトアカウントに、ゼロから始まる符号なしの**ガス払い戻しカウンター**が加わります。3 つのオペコードがこれを管理します。\n\n| オペコード | バイト | スタック | ガス | 効果 |\n| --- | --- | --- | --- | --- |\n| `SELFGAS` | `0x49` | → counter | `SELFBALANCE` と同じ | このアカウントに貯められたガスをプッシュ |\n| `USEGAS` | `0x4a` | amount → | 5000 | `min(amount, counter)` をアカウントからトランザクションの払い戻しカウンターへ移す |\n| `STOREGAS` | `0x4b` | amount → | 5000 + amount | このアカウントのカウンターに `amount` を加算 |\n\n放出されたガスは通常の払い戻しカウンターを通るため、既存の払い戻し上限（当時は使用ガスの 50%）を引き継ぎ、1 つのブロックをどれだけ引き伸ばせるかが制限されます。ガスコストは `SELFBALANCE` と `SSTORE` をモデルにしていました。\n\n## サンプルコード\n\n「今貯めて、後で使う」ための説明用アセンブリです（このオペコードは Ethereum に追加されなかったため、現在のツールではコンパイルできません）。\n\n```text\n; when gas is cheap: bank 100000 gas (costs 5000 + 100000)\nPUSH3 0x0186a0\nSTOREGAS          ; 0x4b\n\n; later, when gas is expensive: release up to 100000 into the refund counter\nPUSH3 0x0186a0\nUSEGAS            ; 0x4a  (costs 5000)\n\n; read the remaining balance\nSELFGAS           ; 0x49\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** で、フォークにスケジュールされたことはありません。\n- 動機は、[EIP-3529](/eip-3529/)（London）によってほぼ消滅しました。この EIP が `SELFDESTRUCT` の払い戻しを廃止し、ストレージクリアの払い戻しと払い戻し上限を引き下げたため、ガストークンは採算が取れなくなりました。\n- 仕様のテストケース表は、仕様自身とは異なるオペコードのバイトを使っているように見えます（たとえば `0x49` が `USEGAS`、`0x4a` が `STOREGAS` のように動作します）。そのため、正確なバイトの割り当ては不明です。\n- オペコードのバイト `0x49`～`0x4b` は、その後ほかの提案で使われています（たとえば `BLOBHASH` は `0x49`、`BLOBBASEFEE` は `0x4a` です）。そのため、これらの割り当てはもう使えません。\n"},"ko":{"lang":"ko","tldr":"컨트랙트가 계정 단위 카운터에 gas를 저축했다가 나중에 트랜잭션의 환급 카운터로 방출할 수 있게 하는 세 가지 옵코드를 제안해, 스토리지를 부풀리는 gas 토큰을 대체하려는 정체(Stagnant) 상태의 제안.","tags":["evm","opcodes","gas","refunds","core"],"related":[3529,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-3322/","markdown":"## 어떤 문제를 해결하나요?\n\n2020년에 gas 토큰(GST2, CHI 등)은 스토리지를 비울 때 주어지는 환급을 이용했습니다. gas가 쌀 때 스토리지 슬롯을 채우거나 컨트랙트를 만들고, gas가 비쌀 때 그것들을 삭제해 환급을 받는 방식입니다. 이는 gas를 한가한 블록에서 붐비는 블록으로 옮기므로 어떤 면에서는 유용하다고 할 수 있지만, **상태에 쓸모없는 데이터를 써 넣는** 방식으로 이를 이뤘기 때문에 모든 노드의 데이터베이스가 부풀었습니다.\n\nEIP-3322는 같은 일을 직접 하자고 제안했습니다. 컨트랙트가 자기 계정의 카운터에 \"gas\"를 저장했다가 나중에 환급 카운터로 방출하게 하면, 쓸모없는 스토리지가 전혀 필요하지 않습니다.\n\n## 어떻게 동작하나요?\n\n모든 컨트랙트 계정에 0에서 시작하는 부호 없는 **gas 환급 카운터**가 생깁니다. 세 가지 옵코드가 이를 관리합니다.\n\n| 옵코드 | 바이트 | 스택 | Gas | 효과 |\n| --- | --- | --- | --- | --- |\n| `SELFGAS` | `0x49` | → counter | `SELFBALANCE`와 동일 | 이 계정에 저장된 gas를 푸시 |\n| `USEGAS` | `0x4a` | amount → | 5000 | `min(amount, counter)`를 계정에서 트랜잭션의 환급 카운터로 이동 |\n| `STOREGAS` | `0x4b` | amount → | 5000 + amount | 이 계정의 카운터에 `amount`를 더함 |\n\n방출된 gas는 일반 환급 카운터를 거치므로 기존의 환급 상한(당시에는 사용한 gas의 50%)을 그대로 적용받아, 어느 한 블록을 얼마나 늘릴 수 있는지가 제한됩니다. gas 비용은 `SELFBALANCE`와 `SSTORE`를 본떠 정했습니다.\n\n## 샘플 코드\n\n\"지금 저축하고 나중에 쓰기\"를 보여 주는 설명용 어셈블리입니다(이 옵코드들은 이더리움에 추가된 적이 없으므로 현재 도구로는 컴파일되지 않습니다).\n\n```text\n; when gas is cheap: bank 100000 gas (costs 5000 + 100000)\nPUSH3 0x0186a0\nSTOREGAS          ; 0x4b\n\n; later, when gas is expensive: release up to 100000 into the refund counter\nPUSH3 0x0186a0\nUSEGAS            ; 0x4a  (costs 5000)\n\n; read the remaining balance\nSELFGAS           ; 0x49\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**이며, 포크에 일정이 잡힌 적이 없습니다.\n- 동기는 [EIP-3529](/eip-3529/)(런던)와 함께 대부분 사라졌습니다. 이 EIP가 `SELFDESTRUCT` 환급을 없애고 스토리지 비우기 환급과 환급 상한을 줄여 gas 토큰이 수익성을 잃었습니다.\n- 명세의 테스트 케이스 표는 자체 명세와 다른 옵코드 바이트를 쓰는 것으로 보입니다(예: `0x49`가 `USEGAS`처럼, `0x4a`가 `STOREGAS`처럼 동작). 따라서 정확한 바이트 배정은 불분명합니다.\n- 옵코드 바이트 `0x49`~`0x4b`는 이후 다른 제안들이 사용했으므로(예: `BLOBHASH`는 `0x49`, `BLOBBASEFEE`는 `0x4a`), 이 배정들은 더 이상 쓸 수 없습니다.\n"},"zh":{"lang":"zh","tldr":"一项停滞（Stagnant）的提案：用三个操作码让合约把 gas 存入账户级计数器，之后再释放到交易的退款计数器中，以取代会造成存储膨胀的 gas 代币。","tags":["evm","opcodes","gas","refunds","core"],"related":[3529,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-3322/","markdown":"## 它解决什么问题？\n\n2020 年，gas 代币（GST2、CHI 等）利用了清除存储时的退款：在 gas 便宜时填充存储槽或创建合约，在 gas 昂贵时删除它们并领取退款。这把 gas 从清闲的区块转移到繁忙的区块，这一点或许有用，但它是靠**向状态中写入无用数据**来实现的，导致每个节点的数据库膨胀。\n\nEIP-3322 提议直接做同样的事：让合约在其账户的计数器中存储“gas”，之后再把它释放到退款计数器中，不涉及任何垃圾存储。\n\n## 它如何运作\n\n每个合约账户都增加一个无符号的 **gas 退款计数器**，初始为零。三个操作码负责管理它：\n\n| 操作码 | 字节 | 栈 | Gas | 作用 |\n| --- | --- | --- | --- | --- |\n| `SELFGAS` | `0x49` | → counter | 与 `SELFBALANCE` 相同 | 压入该账户存储的 gas |\n| `USEGAS` | `0x4a` | amount → | 5000 | 把 `min(amount, counter)` 从账户转移到交易的退款计数器 |\n| `STOREGAS` | `0x4b` | amount → | 5000 + amount | 把 `amount` 加到该账户的计数器上 |\n\n由于释放出来的 gas 要经过正常的退款计数器，它沿用了现有的退款上限（当时为已用 gas 的 50%），这限制了它能把任何一个区块撑大多少。gas 成本参照 `SELFBALANCE` 和 `SSTORE` 设定。\n\n## 示例代码\n\n“现在存入，以后使用”的示意汇编（这些操作码从未被加入以太坊，因此用现有工具无法编译）：\n\n```text\n; when gas is cheap: bank 100000 gas (costs 5000 + 100000)\nPUSH3 0x0186a0\nSTOREGAS          ; 0x4b\n\n; later, when gas is expensive: release up to 100000 into the refund counter\nPUSH3 0x0186a0\nUSEGAS            ; 0x4a  (costs 5000)\n\n; read the remaining balance\nSELFGAS           ; 0x49\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**；它从未被排入分叉计划。\n- 随着 [EIP-3529](/eip-3529/)（伦敦升级）的出现，其动机基本消失：该 EIP 取消了 `SELFDESTRUCT` 的退款，并降低了清除存储的退款和退款上限，使 gas 代币无利可图。\n- 规范中的测试用例表所用的操作码字节似乎与其自身的规范不同（例如 `0x49` 的行为像 `USEGAS`，`0x4a` 像 `STOREGAS`），因此具体的字节分配并不明确。\n- 操作码字节 `0x49`–`0x4b` 此后已被其他提案使用（例如 `BLOBHASH` 是 `0x49`，`BLOBBASEFEE` 是 `0x4a`），所以这些分配已不再可用。\n"}}}
