{"eip":1153,"title":"Transient storage opcodes","description":"Add opcodes for manipulating state that behaves almost identically to storage but is discarded after every transaction","authors":["Alexey Akhunov (@AlexeyAkhunov)","Moody Salem (@moodysalem)"],"status":"Final","type":"Standards Track","category":"Core","created":"2018-06-15","requires":[2200,3529],"discussionsTo":"https://ethereum-magicians.org/t/eip-transient-storage-opcodes/553","repo":"EIPs","label":"EIP-1153","officialUrl":"https://eips.ethereum.org/EIPS/eip-1153","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1153.md","url":"https://eips.huatuo.xyz/eip-1153/","tldr":{"en":"Adds TLOAD and TSTORE, a storage-like key/value space that is wiped at the end of every transaction, making reentrancy locks and in-transaction callbacks cheap.","ja":"TLOAD と TSTORE を追加する。ストレージのようなキー・バリュー空間で、トランザクションの終了時に消去されるため、リエントランシーロックやトランザクション内コールバックを安価に実現できる。","ko":"TLOAD와 TSTORE를 추가한다. 스토리지와 비슷한 키-값 공간으로 트랜잭션이 끝날 때마다 비워지므로, 재진입 락과 트랜잭션 내 콜백을 저렴하게 만든다.","zh":"新增 TLOAD 和 TSTORE，一个类似存储的键值空间，在每笔交易结束时清空，使重入锁和交易内回调变得低成本。"},"tags":["evm","opcodes","storage","gas","cancun"],"explainers":{"en":{"lang":"en","tldr":"Adds TLOAD and TSTORE, a storage-like key/value space that is wiped at the end of every transaction, making reentrancy locks and in-transaction callbacks cheap.","tags":["evm","opcodes","storage","gas","cancun"],"related":[2200,3529,2929,7609],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1153/","markdown":"## What problem does it solve?\n\nA single transaction can run through many nested calls, and the same contract can be re-entered several times. Those call frames often need to share a bit of state: \"am I already inside this function?\" for a reentrancy lock, \"how much does the caller owe me so far?\" for a flash-swap style callback.\n\nBefore this EIP the only shared place was regular storage (`SSTORE`/`SLOAD`). That is expensive, and since [EIP-3529](/eip-3529/) refunds for clearing a slot are capped at 20 % of the transaction's gas, so the \"set then reset\" pattern rarely gets its money back. Passing values through calldata does not work when an untrusted contract sits in the middle of the call chain.\n\n## How it works\n\nTwo new opcodes:\n\n| Opcode | Byte | Stack | Gas |\n| --- | --- | --- | --- |\n| `TLOAD` | `0x5c` | `key → value` | 100 (like a warm `SLOAD`) |\n| `TSTORE` | `0x5d` | `key, value →` | 100 (like a warm `SSTORE` of a dirty slot) |\n\n- Addressing is the same as storage: each contract has its own map of 32-byte keys to 32-byte values.\n- **Everything is discarded at the end of the transaction.** Nothing ever touches disk, so there are no cold/warm surprises and no refunds.\n- It is private to the contract, like storage. Under `DELEGATECALL`/`CALLCODE` the caller's transient storage is used; under `CALL`/`STATICCALL` the callee's.\n- If a call frame reverts, its transient writes (including those of inner calls) are reverted too.\n- `TSTORE` inside a `STATICCALL` throws; `TLOAD` is allowed.\n- Unlike `SSTORE`, `TSTORE` does not have the [EIP-2200](/eip-2200/) rule that fails when only the 2,300-gas stipend is left.\n\nUse cases listed in the spec include reentrancy locks, single-transaction ERC-20 approvals, \"till\" patterns that check balances are settled at the end of a callback, and passing metadata to proxies without calldata.\n\n## Sample code\n\nA reentrancy guard using transient storage (Solidity inline assembly, 0.8.24 or later):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\nabstract contract TransientReentrancyGuard {\n    // Any fixed slot works; it is cleared automatically after the tx.\n    bytes32 private constant LOCK = keccak256(\"example.reentrancy.lock\");\n\n    modifier nonReentrant() {\n        bytes32 slot = LOCK;\n        assembly {\n            if tload(slot) { revert(0, 0) }\n            tstore(slot, 1)\n        }\n        _;\n        assembly {\n            tstore(slot, 0) // reset so later calls in the same tx work\n        }\n    }\n}\n\ncontract Vault is TransientReentrancyGuard {\n    mapping(address =\u003e uint256) public balance;\n\n    function withdraw(uint256 amount) external nonReentrant {\n        balance[msg.sender] -= amount;\n        (bool ok, ) = msg.sender.call{value: amount}(\"\");\n        require(ok);\n    }\n}\n```\n\n## Things to know\n\n- **Final** and live on Ethereum Mainnet since the Cancun upgrade (Dencun), together with other EVM changes such as `MCOPY` ([EIP-5656](/eip-5656/)).\n- \"Transient\" means per **transaction**, not per call. Values survive across calls within the same transaction, so reset slots you rely on (e.g. a lock) instead of assuming they start at zero on the next call.\n- Do not use it as a substitute for memory: memory is cleared when a call returns, transient storage is not, which can cause surprising behaviour on reentrancy.\n- Newer Solidity versions also offer a `transient` keyword for state variables; check your compiler version and EVM target before relying on it.\n- [EIP-7609](/eip-7609/) proposed lowering the cost of these opcodes further, but it is Stagnant.\n"},"ja":{"lang":"ja","tldr":"TLOAD と TSTORE を追加する。ストレージのようなキー・バリュー空間で、トランザクションの終了時に消去されるため、リエントランシーロックやトランザクション内コールバックを安価に実現できる。","tags":["evm","opcodes","storage","gas","cancun"],"related":[2200,3529,2929,7609],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1153/","markdown":"## 何を解決するのか\n\n1 つのトランザクションは多数の入れ子の呼び出しを実行することがあり、同じコントラクトが何度も再入されることもあります。これらの呼び出しフレームは、少量の状態を共有する必要がよくあります。リエントランシーロックなら「すでにこの関数の中にいるか」、フラッシュスワップ型のコールバックなら「呼び出し元はここまでにいくら支払う必要があるか」です。\n\nこの EIP 以前に共有できる場所は通常のストレージ（`SSTORE`/`SLOAD`）だけでした。これは高価で、さらに [EIP-3529](/eip-3529/) 以降はスロットを消去した際の払い戻しがトランザクション gas の 20 % に制限されているため、「設定してからリセットする」パターンでは費用がほとんど戻りません。呼び出しチェーンの途中に信頼できないコントラクトが挟まる場合、calldata で値を渡す方法も機能しません。\n\n## 仕組み\n\n新しいオペコードが 2 つあります。\n\n| オペコード | バイト | スタック | Gas |\n| --- | --- | --- | --- |\n| `TLOAD` | `0x5c` | `key → value` | 100（ウォームな `SLOAD` と同じ） |\n| `TSTORE` | `0x5d` | `key, value →` | 100（ダーティなスロットへのウォームな `SSTORE` と同じ） |\n\n- アドレッシングはストレージと同じです。各コントラクトが、32 バイトのキーから 32 バイトの値へのマップを個別に持ちます。\n- **すべてはトランザクションの終了時に破棄されます。** ディスクには一切触れないため、コールド/ウォームによる予想外のコストも払い戻しもありません。\n- ストレージと同様に、コントラクトごとに独立しています。`DELEGATECALL`/`CALLCODE` では呼び出し元の一時ストレージが、`CALL`/`STATICCALL` では呼び出し先のものが使われます。\n- 呼び出しフレームが revert されると、そのフレーム（内部呼び出しのものを含む）の一時的な書き込みも revert されます。\n- `STATICCALL` 内の `TSTORE` は例外になります。`TLOAD` は許可されます。\n- `SSTORE` と異なり、`TSTORE` には、2,300 gas のスタイペンドしか残っていない場合に失敗する [EIP-2200](/eip-2200/) のルールがありません。\n\n仕様が挙げるユースケースには、リエントランシーロック、単一トランザクション内の ERC-20 承認、コールバックの最後に残高が精算されているかを確認する「till」パターン、calldata を使わずにプロキシへメタデータを渡すことなどがあります。\n\n## サンプルコード\n\n一時ストレージを使ったリエントランシーガード（Solidity のインラインアセンブリ、0.8.24 以降）:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\nabstract contract TransientReentrancyGuard {\n    // Any fixed slot works; it is cleared automatically after the tx.\n    bytes32 private constant LOCK = keccak256(\"example.reentrancy.lock\");\n\n    modifier nonReentrant() {\n        bytes32 slot = LOCK;\n        assembly {\n            if tload(slot) { revert(0, 0) }\n            tstore(slot, 1)\n        }\n        _;\n        assembly {\n            tstore(slot, 0) // reset so later calls in the same tx work\n        }\n    }\n}\n\ncontract Vault is TransientReentrancyGuard {\n    mapping(address =\u003e uint256) public balance;\n\n    function withdraw(uint256 amount) external nonReentrant {\n        balance[msg.sender] -= amount;\n        (bool ok, ) = msg.sender.call{value: amount}(\"\");\n        require(ok);\n    }\n}\n```\n\n## 知っておくべきこと\n\n- **Final** で、`MCOPY`（[EIP-5656](/eip-5656/)）などの他の EVM 変更とともに、Cancun アップグレード（Dencun）以降 Ethereum メインネットで有効です。\n- 「一時的（transient）」とは、呼び出しごとではなく**トランザクション**ごとという意味です。値は同じトランザクション内の複数の呼び出しをまたいで残るため、依存するスロット（たとえばロック）は、次の呼び出しで 0 から始まると仮定せず、必ずリセットしてください。\n- メモリの代わりとして使わないでください。メモリは呼び出しが戻るときにクリアされますが、一時ストレージはされないため、再入時に予想外の動作を招くことがあります。\n- 新しい Solidity では、状態変数用の `transient` キーワードも使えます。依存する前に、コンパイラのバージョンと EVM ターゲットを確認してください。\n- [EIP-7609](/eip-7609/) はこれらのオペコードのコストをさらに下げることを提案しましたが、Stagnant です。\n"},"ko":{"lang":"ko","tldr":"TLOAD와 TSTORE를 추가한다. 스토리지와 비슷한 키-값 공간으로 트랜잭션이 끝날 때마다 비워지므로, 재진입 락과 트랜잭션 내 콜백을 저렴하게 만든다.","tags":["evm","opcodes","storage","gas","cancun"],"related":[2200,3529,2929,7609],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1153/","markdown":"## 어떤 문제를 해결하나요?\n\n하나의 트랜잭션은 중첩된 많은 호출을 거칠 수 있고, 같은 컨트랙트가 여러 번 재진입될 수도 있습니다. 이런 호출 프레임들은 약간의 상태를 공유해야 할 때가 많습니다. 재진입 락이라면 \"내가 이미 이 함수 안에 있는가\", 플래시 스왑 방식의 콜백이라면 \"호출자가 지금까지 나에게 얼마를 빚졌는가\" 같은 것입니다.\n\n이 EIP 이전에 공유할 수 있는 곳은 일반 스토리지(`SSTORE`/`SLOAD`)뿐이었습니다. 이는 비싸고, [EIP-3529](/eip-3529/) 이후로는 슬롯을 비울 때의 환불이 트랜잭션 gas의 20 %로 제한되어 \"설정했다가 초기화하는\" 패턴은 비용을 거의 돌려받지 못합니다. 호출 체인 중간에 신뢰할 수 없는 컨트랙트가 끼어 있으면 calldata로 값을 넘기는 방법도 통하지 않습니다.\n\n## 어떻게 동작하나요?\n\n새 opcode가 두 개 있습니다.\n\n| Opcode | 바이트 | 스택 | Gas |\n| --- | --- | --- | --- |\n| `TLOAD` | `0x5c` | `key → value` | 100 (웜 `SLOAD`와 같음) |\n| `TSTORE` | `0x5d` | `key, value →` | 100 (더티 슬롯에 대한 웜 `SSTORE`와 같음) |\n\n- 주소 지정 방식은 스토리지와 같습니다. 각 컨트랙트는 32바이트 키에서 32바이트 값으로 가는 자기만의 맵을 갖습니다.\n- **모든 것은 트랜잭션이 끝날 때 폐기됩니다.** 디스크를 전혀 건드리지 않으므로 콜드/웜에 따른 예상 밖의 비용도, 환불도 없습니다.\n- 스토리지처럼 컨트랙트마다 비공개입니다. `DELEGATECALL`/`CALLCODE`에서는 호출자의 일시적 스토리지가, `CALL`/`STATICCALL`에서는 피호출자의 것이 쓰입니다.\n- 호출 프레임이 revert되면 그 프레임(내부 호출의 것 포함)의 일시적 쓰기도 revert됩니다.\n- `STATICCALL` 안의 `TSTORE`는 예외를 발생시키고, `TLOAD`는 허용됩니다.\n- `SSTORE`와 달리 `TSTORE`에는 2,300 gas 스티펜드만 남았을 때 실패하는 [EIP-2200](/eip-2200/)의 규칙이 없습니다.\n\n명세가 나열하는 사용 사례에는 재진입 락, 단일 트랜잭션 ERC-20 승인, 콜백이 끝날 때 잔액이 정산되었는지 확인하는 \"till\" 패턴, calldata 없이 프록시에 메타데이터를 전달하는 것 등이 있습니다.\n\n## 샘플 코드\n\n일시적 스토리지를 사용하는 재진입 가드(Solidity 인라인 어셈블리, 0.8.24 이상):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\nabstract contract TransientReentrancyGuard {\n    // Any fixed slot works; it is cleared automatically after the tx.\n    bytes32 private constant LOCK = keccak256(\"example.reentrancy.lock\");\n\n    modifier nonReentrant() {\n        bytes32 slot = LOCK;\n        assembly {\n            if tload(slot) { revert(0, 0) }\n            tstore(slot, 1)\n        }\n        _;\n        assembly {\n            tstore(slot, 0) // reset so later calls in the same tx work\n        }\n    }\n}\n\ncontract Vault is TransientReentrancyGuard {\n    mapping(address =\u003e uint256) public balance;\n\n    function withdraw(uint256 amount) external nonReentrant {\n        balance[msg.sender] -= amount;\n        (bool ok, ) = msg.sender.call{value: amount}(\"\");\n        require(ok);\n    }\n}\n```\n\n## 알아둘 점\n\n- **Final** 상태이며 `MCOPY`([EIP-5656](/eip-5656/)) 같은 다른 EVM 변경과 함께 Cancun 업그레이드(Dencun) 이후 이더리움 메인넷에서 동작합니다.\n- \"일시적(transient)\"은 호출 단위가 아니라 **트랜잭션** 단위라는 뜻입니다. 값은 같은 트랜잭션 안의 호출들을 넘어 유지되므로, 의존하는 슬롯(예: 락)은 다음 호출에서 0으로 시작한다고 가정하지 말고 직접 초기화하세요.\n- 메모리의 대체재로 쓰지 마세요. 메모리는 호출이 반환될 때 지워지지만 일시적 스토리지는 그렇지 않아 재진입 시 예상치 못한 동작이 생길 수 있습니다.\n- 최신 Solidity 버전은 상태 변수용 `transient` 키워드도 제공합니다. 의존하기 전에 컴파일러 버전과 EVM 타깃을 확인하세요.\n- [EIP-7609](/eip-7609/)는 이 opcode들의 비용을 더 낮추자고 제안했지만 Stagnant 상태입니다.\n"},"zh":{"lang":"zh","tldr":"新增 TLOAD 和 TSTORE，一个类似存储的键值空间，在每笔交易结束时清空，使重入锁和交易内回调变得低成本。","tags":["evm","opcodes","storage","gas","cancun"],"related":[2200,3529,2929,7609],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1153/","markdown":"## 它解决什么问题？\n\n一笔交易可以经过许多嵌套调用，同一个合约也可能被多次重入。这些调用帧常常需要共享一点状态：重入锁要知道“我是否已经在这个函数里了”，闪电兑换式的回调要知道“调用者到目前为止欠我多少”。\n\n在这份 EIP 之前，唯一的共享位置是普通存储（`SSTORE`/`SLOAD`）。它很昂贵，而且自 [EIP-3529](/eip-3529/) 起，清除存储槽的退款被限制为交易 gas 的 20 %，所以“先设置再重置”的模式很难把成本收回来。当调用链中间有不受信任的合约时，通过 calldata 传值也行不通。\n\n## 它如何运作\n\n两个新操作码：\n\n| 操作码 | 字节 | 栈 | Gas |\n| --- | --- | --- | --- |\n| `TLOAD` | `0x5c` | `key → value` | 100（与热的 `SLOAD` 相同） |\n| `TSTORE` | `0x5d` | `key, value →` | 100（与对脏槽位的热 `SSTORE` 相同） |\n\n- 寻址方式与存储相同：每个合约都有自己的从 32 字节键到 32 字节值的映射。\n- **一切都会在交易结束时被丢弃。** 它从不接触磁盘，因此没有冷/热访问的意外开销，也没有退款。\n- 与存储一样，它对合约是私有的。在 `DELEGATECALL`/`CALLCODE` 下使用调用者的瞬态存储；在 `CALL`/`STATICCALL` 下使用被调用者的。\n- 如果某个调用帧回滚，它的瞬态写入（包括内部调用的写入）也会一并回滚。\n- 在 `STATICCALL` 中执行 `TSTORE` 会抛出异常；`TLOAD` 是允许的。\n- 与 `SSTORE` 不同，`TSTORE` 没有 [EIP-2200](/eip-2200/) 中“仅剩 2,300 gas 津贴时失败”的规则。\n\n规范列出的用例包括重入锁、单笔交易内的 ERC-20 授权、在回调结束时检查余额是否已结清的“till”模式，以及无需 calldata 就向代理传递元数据。\n\n## 示例代码\n\n使用瞬态存储的重入保护（Solidity 内联汇编，0.8.24 或更高版本）：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\nabstract contract TransientReentrancyGuard {\n    // Any fixed slot works; it is cleared automatically after the tx.\n    bytes32 private constant LOCK = keccak256(\"example.reentrancy.lock\");\n\n    modifier nonReentrant() {\n        bytes32 slot = LOCK;\n        assembly {\n            if tload(slot) { revert(0, 0) }\n            tstore(slot, 1)\n        }\n        _;\n        assembly {\n            tstore(slot, 0) // reset so later calls in the same tx work\n        }\n    }\n}\n\ncontract Vault is TransientReentrancyGuard {\n    mapping(address =\u003e uint256) public balance;\n\n    function withdraw(uint256 amount) external nonReentrant {\n        balance[msg.sender] -= amount;\n        (bool ok, ) = msg.sender.call{value: amount}(\"\");\n        require(ok);\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Final**，自 Cancun 升级（Dencun）起已在以太坊主网上线，同时上线的还有 `MCOPY`（[EIP-5656](/eip-5656/)）等其他 EVM 改动。\n- “瞬态（transient）”指的是按**交易**，而不是按调用。值在同一笔交易内的多次调用之间会保留，所以对你依赖的槽位（例如锁）要主动重置，而不要假定下一次调用时它从零开始。\n- 不要把它当作内存的替代品：内存在调用返回时被清除，而瞬态存储不会，这可能在重入时造成意外行为。\n- 较新的 Solidity 版本也为状态变量提供了 `transient` 关键字；依赖它之前请检查编译器版本和 EVM 目标。\n- [EIP-7609](/eip-7609/) 曾提议进一步降低这些操作码的成本，但状态为 Stagnant。\n"}},"requiredBy":[7569,7609,7664,7674,7877,7971,8000,8273,8360]}
