{"eip":8125,"title":"Temporary Contract Storage","description":"Adds bounded-lifetime contract storage via TMPLOAD/TMPSTORE opcodes that is automatically cleared on a fixed schedule.","authors":["Wei Han Ng (@weiihann)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2026-01-14","requires":[2200,2929],"discussionsTo":"https://ethereum-magicians.org/t/eip8125-temporary-contract-storage/27440","repo":"EIPs","label":"EIP-8125","officialUrl":"https://eips.ethereum.org/EIPS/eip-8125","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8125.md","url":"https://eips.huatuo.xyz/eip-8125/","tldr":{"en":"Adds TMPLOAD/TMPSTORE opcodes for contract storage that survives across transactions and blocks but is wiped automatically on a fixed schedule, giving short-lived data a home that does not grow Ethereum's state forever.","ja":"トランザクションやブロックをまたいで残るが、決まったスケジュールで自動的に消去されるコントラクトストレージのために、TMPLOAD/TMPSTORE オペコードを追加する。短命なデータに、Ethereum のステートを永遠に肥大化させない置き場所を与える。","ko":"트랜잭션과 블록을 넘어 유지되지만 정해진 일정에 따라 자동으로 지워지는 컨트랙트 스토리지를 위해 TMPLOAD/TMPSTORE opcode를 추가한다. 단명하는 데이터에 이더리움 상태를 영원히 키우지 않는 보관 장소를 준다.","zh":"新增 TMPLOAD/TMPSTORE 操作码，提供一种可跨交易和区块保留、但会按固定周期自动清除的合约存储，让短期数据有了一个不会让以太坊状态永远增长的存放处。"},"tags":["evm","storage","state-growth","opcodes","core"],"explainers":{"en":{"lang":"en","tldr":"Adds TMPLOAD/TMPSTORE opcodes for contract storage that survives across transactions and blocks but is wiped automatically on a fixed schedule, giving short-lived data a home that does not grow Ethereum's state forever.","tags":["evm","storage","state-growth","opcodes","core"],"related":[1153,2929,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8125/","markdown":"## What problem does it solve?\n\nContracts today have two places to keep data: permanent storage (`SSTORE`), which stays in the state forever unless explicitly deleted, and transient storage ([EIP-1153](/eip-1153/)), which is gone at the end of the transaction. Many applications need something in between: data that matters for a while (minutes, days) and then becomes useless. They put it in permanent storage, and most of it is never cleaned up. The spec cites data showing over 60 % of storage slots are written once and never accessed again.\n\nTemporary storage gives that data a bounded lifetime, so nodes do not carry it forever.\n\n## How it works\n\n- Two new opcodes: `TMPSTORE(key, value)` and `TMPLOAD(key)`, scoped to the executing contract like `SSTORE`/`SLOAD`.\n- Values live in the storage tries of **two reserved system accounts**, under the slot `keccak256(contract_address || key)`.\n- Time is split into **periods** of `TEMP_STORAGE_PERIOD` blocks. The two system accounts take turns being \"current\" and \"previous\". At the first block of a new period, the account becoming current has its `storageRoot` reset to empty, a constant-time operation.\n- `TMPSTORE` writes non-zero values to the current account; writing `0` deletes the slot from both accounts.\n- `TMPLOAD` reads from the current account and falls back to the previous one.\n\nThe result: anything written is readable for **at least one full period and at most two**, regardless of when in the period it was written. Gas is meant to be well below `SSTORE`/`SLOAD` but above `TSTORE`/`TLOAD`, with no refunds for clearing; exact values are still TBD.\n\n## Sample code\n\nThe opcodes have no Solidity syntax yet; the rollover logic as pseudocode:\n\n```python\ndef period_index(n):\n    return (n - FORK_BLOCK) // TEMP_STORAGE_PERIOD\n\ndef accounts(n):\n    if period_index(n) % 2 == 0:\n        return ADDR_0, ADDR_1    # (current, previous)\n    return ADDR_1, ADDR_0\n\ndef on_block_start(block, parent):\n    if period_index(block.number) \u003e period_index(parent.number):\n        current, _ = accounts(block.number)\n        state[current].storage_root = EMPTY_TRIE_ROOT   # drop data older than one period\n\ndef tmpload(contract, key, n):\n    cur, prev = accounts(n)\n    slot = keccak256(contract + key)\n    return state[cur].storage.get(slot) or state[prev].storage.get(slot, 0)\n```\n\n## Things to know\n\n- Status is **Draft**. The period length, system addresses, fork block and all gas costs are still TBD.\n- Contracts must treat temporary storage as ephemeral and handle entries that have already expired.\n- Unlike transient storage, the data does persist across transactions and blocks, so it still costs nodes something; gas must be calibrated to avoid disk I/O DoS.\n- Requires a hard fork; existing opcodes are unchanged.\n"},"ja":{"lang":"ja","tldr":"トランザクションやブロックをまたいで残るが、決まったスケジュールで自動的に消去されるコントラクトストレージのために、TMPLOAD/TMPSTORE オペコードを追加する。短命なデータに、Ethereum のステートを永遠に肥大化させない置き場所を与える。","tags":["evm","storage","state-growth","opcodes","core"],"related":[1153,2929,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8125/","markdown":"## 何を解決するのか\n\n現在、コントラクトがデータを置ける場所は 2 つあります。明示的に削除しない限り永久にステートに残る永続ストレージ（`SSTORE`）と、トランザクションの終了時に消える transient storage（[EIP-1153](/eip-1153/)）です。多くのアプリケーションが必要としているのはその中間、つまりしばらくの間（数分、数日）は意味があり、その後は不要になるデータです。それを永続ストレージに置いてしまうため、大半は片付けられないままになります。仕様は、ストレージスロットの 60 % 超が一度書かれたきり二度とアクセスされないことを示すデータを挙げています。\n\n一時ストレージ（temporary storage）はそのようなデータに有限の寿命を与え、ノードが永遠に抱え込まなくて済むようにします。\n\n## 仕組み\n\n- 2 つの新しいオペコード `TMPSTORE(key, value)` と `TMPLOAD(key)`。`SSTORE`/`SLOAD` と同様に、実行中のコントラクトにスコープされます。\n- 値は、スロット `keccak256(contract_address || key)` の下で、**予約された 2 つのシステムアカウント**のストレージトライに保存されます。\n- 時間は `TEMP_STORAGE_PERIOD` ブロックごとの**期間（period）**に分割されます。2 つのシステムアカウントが交互に「current」と「previous」になります。新しい期間の最初のブロックで、current になるアカウントの `storageRoot` は空にリセットされます。これは定数時間の操作です。\n- `TMPSTORE` は 0 以外の値を current アカウントに書き込みます。`0` を書き込むと、両方のアカウントからそのスロットが削除されます。\n- `TMPLOAD` は current アカウントから読み、なければ previous アカウントにフォールバックします。\n\nその結果、書き込まれたものは、期間内のいつ書き込まれたかにかかわらず、**少なくとも 1 期間分、最大でも 2 期間分**は読み出せます。ガスは `SSTORE`/`SLOAD` よりかなり安く、`TSTORE`/`TLOAD` よりは高くなる想定で、消去による払い戻しはありません。具体的な値はまだ未定（TBD）です。\n\n## サンプルコード\n\nこのオペコードにはまだ Solidity の構文がありません。ロールオーバーのロジックを擬似コードで示します。\n\n```python\ndef period_index(n):\n    return (n - FORK_BLOCK) // TEMP_STORAGE_PERIOD\n\ndef accounts(n):\n    if period_index(n) % 2 == 0:\n        return ADDR_0, ADDR_1    # (current, previous)\n    return ADDR_1, ADDR_0\n\ndef on_block_start(block, parent):\n    if period_index(block.number) \u003e period_index(parent.number):\n        current, _ = accounts(block.number)\n        state[current].storage_root = EMPTY_TRIE_ROOT   # drop data older than one period\n\ndef tmpload(contract, key, n):\n    cur, prev = accounts(n)\n    slot = keccak256(contract + key)\n    return state[cur].storage.get(slot) or state[prev].storage.get(slot, 0)\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。期間の長さ、システムアドレス、フォークブロック、すべてのガスコストはまだ未定です。\n- コントラクトは、一時ストレージを揮発的なものとして扱い、すでに期限切れになったエントリを処理しなければなりません。\n- transient storage と違い、データはトランザクションやブロックをまたいで残るため、ノードにはやはりコストがかかります。ディスク I/O を狙った DoS を避けるよう、ガスを調整する必要があります。\n- ハードフォークが必要です。既存のオペコードは変わりません。\n"},"ko":{"lang":"ko","tldr":"트랜잭션과 블록을 넘어 유지되지만 정해진 일정에 따라 자동으로 지워지는 컨트랙트 스토리지를 위해 TMPLOAD/TMPSTORE opcode를 추가한다. 단명하는 데이터에 이더리움 상태를 영원히 키우지 않는 보관 장소를 준다.","tags":["evm","storage","state-growth","opcodes","core"],"related":[1153,2929,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8125/","markdown":"## 어떤 문제를 해결하나요?\n\n지금 컨트랙트가 데이터를 둘 수 있는 곳은 두 군데입니다. 명시적으로 지우지 않으면 상태에 영원히 남는 영구 스토리지(`SSTORE`)와, 트랜잭션이 끝나면 사라지는 transient storage([EIP-1153](/eip-1153/))입니다. 많은 애플리케이션에는 그 중간, 즉 한동안(몇 분, 며칠)은 의미가 있다가 이후에는 쓸모없어지는 데이터가 필요합니다. 이런 데이터를 영구 스토리지에 넣다 보니 대부분 정리되지 않습니다. 스펙은 스토리지 슬롯의 60 % 이상이 한 번 쓰인 뒤 다시는 접근되지 않는다는 데이터를 인용합니다.\n\n임시 스토리지(temporary storage)는 이런 데이터에 한정된 수명을 주어 노드가 영원히 들고 있지 않게 합니다.\n\n## 어떻게 동작하나요?\n\n- 새 opcode 두 개: `TMPSTORE(key, value)`와 `TMPLOAD(key)`. `SSTORE`/`SLOAD`처럼 실행 중인 컨트랙트로 범위가 한정됩니다.\n- 값은 **예약된 시스템 계정 두 개**의 스토리지 트라이에 슬롯 `keccak256(contract_address || key)`로 저장됩니다.\n- 시간은 `TEMP_STORAGE_PERIOD` 블록 단위의 **기간(period)** 으로 나뉩니다. 두 시스템 계정이 번갈아 \"현재(current)\"와 \"이전(previous)\"이 됩니다. 새 기간의 첫 블록에서 현재가 되는 계정의 `storageRoot`는 빈 값으로 초기화되며, 이는 상수 시간 연산입니다.\n- `TMPSTORE`는 0이 아닌 값을 현재 계정에 씁니다. `0`을 쓰면 두 계정 모두에서 슬롯이 삭제됩니다.\n- `TMPLOAD`는 현재 계정에서 읽고, 없으면 이전 계정으로 폴백합니다.\n\n결과적으로 기록된 값은 기간 중 언제 쓰였든 **최소 한 기간 전체, 최대 두 기간** 동안 읽을 수 있습니다. 가스는 `SSTORE`/`SLOAD`보다 훨씬 낮고 `TSTORE`/`TLOAD`보다는 높게 설계되며, 지울 때 환급은 없습니다. 정확한 값은 아직 미정(TBD)입니다.\n\n## 샘플 코드\n\n이 opcode에는 아직 Solidity 문법이 없습니다. 롤오버 로직을 의사 코드로 보이면 다음과 같습니다.\n\n```python\ndef period_index(n):\n    return (n - FORK_BLOCK) // TEMP_STORAGE_PERIOD\n\ndef accounts(n):\n    if period_index(n) % 2 == 0:\n        return ADDR_0, ADDR_1    # (current, previous)\n    return ADDR_1, ADDR_0\n\ndef on_block_start(block, parent):\n    if period_index(block.number) \u003e period_index(parent.number):\n        current, _ = accounts(block.number)\n        state[current].storage_root = EMPTY_TRIE_ROOT   # drop data older than one period\n\ndef tmpload(contract, key, n):\n    cur, prev = accounts(n)\n    slot = keccak256(contract + key)\n    return state[cur].storage.get(slot) or state[prev].storage.get(slot, 0)\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다. 기간 길이, 시스템 주소, 포크 블록, 모든 가스 비용이 아직 미정입니다.\n- 컨트랙트는 임시 스토리지를 휘발성으로 취급하고 이미 만료된 항목을 처리해야 합니다.\n- transient storage와 달리 데이터가 트랜잭션과 블록을 넘어 유지되므로 노드에는 여전히 비용이 듭니다. 디스크 I/O DoS를 피하도록 가스를 맞춰야 합니다.\n- 하드포크가 필요합니다. 기존 opcode는 바뀌지 않습니다.\n"},"zh":{"lang":"zh","tldr":"新增 TMPLOAD/TMPSTORE 操作码，提供一种可跨交易和区块保留、但会按固定周期自动清除的合约存储，让短期数据有了一个不会让以太坊状态永远增长的存放处。","tags":["evm","storage","state-growth","opcodes","core"],"related":[1153,2929,2200],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8125/","markdown":"## 它解决什么问题？\n\n目前合约有两个地方可以存数据：永久存储（`SSTORE`），除非显式删除否则永远留在状态中；以及瞬态存储（transient storage，[EIP-1153](/eip-1153/)），在交易结束时消失。许多应用需要介于两者之间的东西：在一段时间内（几分钟、几天）重要、之后就没用的数据。它们把这类数据放进永久存储，而大部分永远不会被清理。规范引用的数据显示，超过 60 % 的存储槽只被写入一次，之后再也没有被访问过。\n\n临时存储（temporary storage）为这类数据设定有限的生命周期，节点就不必永远携带它们。\n\n## 它如何运作\n\n- 两个新操作码：`TMPSTORE(key, value)` 和 `TMPLOAD(key)`，与 `SSTORE`/`SLOAD` 一样作用域限定于正在执行的合约。\n- 值存放在**两个保留系统账户**的存储 trie 中，槽位为 `keccak256(contract_address || key)`。\n- 时间被划分为每段 `TEMP_STORAGE_PERIOD` 个区块的**周期（period）**。两个系统账户轮流充当“当前（current）”和“上一个（previous）”。在新周期的第一个区块，即将成为当前的那个账户的 `storageRoot` 被重置为空，这是一个常数时间的操作。\n- `TMPSTORE` 把非零值写入当前账户；写入 `0` 则会从两个账户中删除该槽位。\n- `TMPLOAD` 从当前账户读取，读不到时回退到上一个账户。\n\n结果是：无论写入发生在周期中的什么时候，写入的内容都**至少可读一个完整周期，最多两个周期**。gas 的设计目标是远低于 `SSTORE`/`SLOAD`，但高于 `TSTORE`/`TLOAD`，且清除时没有退款；具体数值仍待确定（TBD）。\n\n## 示例代码\n\n这些操作码目前还没有 Solidity 语法；轮换逻辑的伪代码如下：\n\n```python\ndef period_index(n):\n    return (n - FORK_BLOCK) // TEMP_STORAGE_PERIOD\n\ndef accounts(n):\n    if period_index(n) % 2 == 0:\n        return ADDR_0, ADDR_1    # (current, previous)\n    return ADDR_1, ADDR_0\n\ndef on_block_start(block, parent):\n    if period_index(block.number) \u003e period_index(parent.number):\n        current, _ = accounts(block.number)\n        state[current].storage_root = EMPTY_TRIE_ROOT   # drop data older than one period\n\ndef tmpload(contract, key, n):\n    cur, prev = accounts(n)\n    slot = keccak256(contract + key)\n    return state[cur].storage.get(slot) or state[prev].storage.get(slot, 0)\n```\n\n## 需要注意\n\n- 状态为 **Draft**。周期长度、系统地址、分叉区块和所有 gas 成本都仍待确定。\n- 合约必须把临时存储视为易失的，并处理已经过期的条目。\n- 与瞬态存储不同，数据确实会跨交易和区块保留，因此仍会给节点带来一定成本；gas 必须经过校准，以避免磁盘 I/O 类的 DoS。\n- 需要硬分叉；现有操作码不变。\n"}}}
