{"eip":2929,"title":"Gas cost increases for state access opcodes","description":"Increases gas cost for SLOAD, CALL, BALANCE, EXT and SELFDESTRUCT when used for the first time in a transaction.","authors":["Vitalik Buterin (@vbuterin)","Martin Swende (@holiman)"],"status":"Final","type":"Standards Track","category":"Core","created":"2020-09-01","discussionsTo":"https://ethereum-magicians.org/t/eip-2929-gas-cost-increases-for-state-access-opcodes/4558","repo":"EIPs","label":"EIP-2929","officialUrl":"https://eips.ethereum.org/EIPS/eip-2929","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2929.md","url":"https://eips.huatuo.xyz/eip-2929/","tldr":{"en":"Introduced warm and cold state access: the first touch of an address or storage slot in a transaction costs 2600 or 2100 gas, later touches cost 100, closing a long-standing DoS vector.","ja":"warm と cold の状態アクセスを導入。トランザクション内でアドレスやストレージスロットに初めて触れると 2600 または 2100 gas、以降は 100 gas となり、長年の DoS ベクターを塞いだ。","ko":"warm과 cold 상태 접근을 도입했다. 트랜잭션에서 주소나 스토리지 슬롯을 처음 건드리면 2600 또는 2100 gas, 이후에는 100 gas가 들어, 오랜 DoS 벡터를 막았다.","zh":"引入 warm 与 cold 状态访问：交易中首次访问某个地址或存储槽需 2600 或 2100 gas，之后的访问只需 100，堵住了一个长期存在的 DoS 攻击面。"},"tags":["gas","evm","state","access-lists","berlin"],"explainers":{"en":{"lang":"en","tldr":"Introduced warm and cold state access: the first touch of an address or storage slot in a transaction costs 2600 or 2100 gas, later touches cost 100, closing a long-standing DoS vector.","tags":["gas","evm","state","access-lists","berlin"],"related":[2930,1884,2200,3529,3651],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2929/","markdown":"## What problem does it solve?\n\nOpcodes that read state, such as `SLOAD`, `BALANCE`, `EXTCODESIZE` and the `CALL` family, may force a node to fetch data from disk. They had been underpriced for years. The authors cite research in which deliberately IO-heavy transactions took 20 to 80 seconds to process, compared with milliseconds for an average transaction.\n\nSimply raising every price would have punished contracts that read the same data repeatedly, even though the second read hits a cache. EIP-2929 charges the expensive price only the **first** time something is touched in a transaction. It went live in the Berlin upgrade (April 2021).\n\n## How it works\n\nDuring each transaction the client keeps two sets:\n\n- `accessed_addresses`, pre-filled with the sender, `tx.to` (or the created contract) and all precompiles;\n- `accessed_storage_keys`, a set of `(address, slot)` pairs, starting empty.\n\n| Constant | Gas |\n| --- | --- |\n| `COLD_ACCOUNT_ACCESS_COST` | 2600 |\n| `COLD_SLOAD_COST` | 2100 |\n| `WARM_STORAGE_READ_COST` | 100 |\n\n- **Account access** (`BALANCE`, `EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`, `CALL`, `CALLCODE`, `DELEGATECALL`, `STATICCALL`): 2600 if the address is cold (then mark it warm), otherwise 100. For calls this is charged before the 63/64 gas forwarding rule.\n- **`SLOAD`**: 2100 if the slot is cold, otherwise 100.\n- **`SSTORE`**: adds 2100 if the slot is cold. [EIP-2200](/eip-2200/) parameters are adjusted (`SLOAD_GAS` becomes 100, `SSTORE_RESET_GAS` becomes `5000 - 2100`), so a cold read-modify-write costs about the same as before.\n- **`SELFDESTRUCT`**: adds 2600 if the beneficiary is cold.\n- `CREATE`/`CREATE2` warm the new address immediately.\n- If a call frame reverts, the warm sets roll back to their state before that frame.\n\n## Sample code\n\nGas difference between a cold and a warm read in one transaction:\n\n```solidity\ncontract WarmCold {\n    uint256 public x = 1;\n\n    function readTwice() external view returns (uint256 cold, uint256 warm) {\n        uint256 g = gasleft();\n        uint256 a = x;               // first SLOAD of this slot: cold (2100)\n        cold = g - gasleft();\n        g = gasleft();\n        uint256 b = x;               // same slot again: warm (100)\n        warm = g - gasleft();\n        require(a == b);\n    }\n}\n```\n\n(The measured numbers include a little overhead, and the optimiser may merge the two reads.)\n\nPre-warming with an access list ([EIP-2930](/eip-2930/)), ethers v6:\n\n```ts\nconst tx = await wallet.sendTransaction({\n  to: token,\n  data,\n  accessList: [{ address: token, storageKeys: [balanceSlot] }],\n});\n```\n\n## Things to know\n\n- **Status: Final**, activated in Berlin alongside [EIP-2930](/eip-2930/) access lists, which let a transaction declare addresses and slots up front to pre-pay them at a slightly lower rate and avoid breaking contracts with hard-coded gas.\n- Contracts that forward a fixed amount of gas, or rely on the 2300 gas stipend of `transfer`/`send`, can break when a callee's first storage read now costs 2100. Avoid hard-coded gas amounts.\n- The warm/cold model is the basis for later changes: [EIP-3651](/eip-3651/) pre-warms the block's `COINBASE`, and refund rules were revised in [EIP-3529](/eip-3529/).\n- Reading the same slot repeatedly is now cheap; reading many distinct slots or contracts is what costs gas.\n"},"ja":{"lang":"ja","tldr":"warm と cold の状態アクセスを導入。トランザクション内でアドレスやストレージスロットに初めて触れると 2600 または 2100 gas、以降は 100 gas となり、長年の DoS ベクターを塞いだ。","tags":["gas","evm","state","access-lists","berlin"],"related":[2930,1884,2200,3529,3651],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2929/","markdown":"## 何を解決するのか\n\n`SLOAD`、`BALANCE`、`EXTCODESIZE`、`CALL` 系など、状態を読む opcode は、ノードにディスクからのデータ取得を強いることがあります。これらは長年、価格が低すぎました。作者は、意図的に IO を重くしたトランザクションの処理に 20〜80 秒かかった（平均的なトランザクションではミリ秒）という調査を挙げています。\n\n単にすべての価格を引き上げると、同じデータを繰り返し読むコントラクトまで、2 回目の読み取りがキャッシュに当たるにもかかわらず罰することになります。EIP-2929 は、トランザクション内で何かに**初めて**触れるときにだけ高い価格を課します。Berlin アップグレード（2021 年 4 月）で稼働しました。\n\n## 仕組み\n\n各トランザクションの間、クライアントは 2 つの集合を保持します。\n\n- `accessed_addresses`: 送信者、`tx.to`（または作成されたコントラクト）、すべてのプリコンパイルで初期化されます。\n- `accessed_storage_keys`: `(address, slot)` の組の集合で、空から始まります。\n\n| 定数 | ガス |\n| --- | --- |\n| `COLD_ACCOUNT_ACCESS_COST` | 2600 |\n| `COLD_SLOAD_COST` | 2100 |\n| `WARM_STORAGE_READ_COST` | 100 |\n\n- **アカウントアクセス**（`BALANCE`、`EXTCODESIZE`、`EXTCODECOPY`、`EXTCODEHASH`、`CALL`、`CALLCODE`、`DELEGATECALL`、`STATICCALL`）: アドレスが cold なら 2600（その後 warm にする）、そうでなければ 100。call の場合、これは 63/64 のガス転送ルールの前に課されます。\n- **`SLOAD`**: スロットが cold なら 2100、そうでなければ 100。\n- **`SSTORE`**: スロットが cold なら 2100 を追加。[EIP-2200](/eip-2200/) のパラメーターが調整され（`SLOAD_GAS` は 100、`SSTORE_RESET_GAS` は `5000 - 2100` になる）、cold な read-modify-write のコストは以前とほぼ同じになります。\n- **`SELFDESTRUCT`**: 受益者が cold なら 2600 を追加。\n- `CREATE`/`CREATE2` は新しいアドレスをただちに warm にします。\n- 呼び出しフレームが revert した場合、warm の集合はそのフレームの前の状態に巻き戻ります。\n\n## サンプルコード\n\n1 つのトランザクション内での cold と warm の読み取りのガス差:\n\n```solidity\ncontract WarmCold {\n    uint256 public x = 1;\n\n    function readTwice() external view returns (uint256 cold, uint256 warm) {\n        uint256 g = gasleft();\n        uint256 a = x;               // first SLOAD of this slot: cold (2100)\n        cold = g - gasleft();\n        g = gasleft();\n        uint256 b = x;               // same slot again: warm (100)\n        warm = g - gasleft();\n        require(a == b);\n    }\n}\n```\n\n（計測値には少しオーバーヘッドが含まれ、オプティマイザーが 2 つの読み取りを統合することもあります。）\n\nアクセスリスト（[EIP-2930](/eip-2930/)）による事前の warm 化、ethers v6:\n\n```ts\nconst tx = await wallet.sendTransaction({\n  to: token,\n  data,\n  accessList: [{ address: token, storageKeys: [balanceSlot] }],\n});\n```\n\n## 知っておくべきこと\n\n- **ステータス: Final**。[EIP-2930](/eip-2930/) のアクセスリストとともに Berlin で有効化されました。アクセスリストを使うと、トランザクションがアドレスやスロットを事前に宣言して、やや低いレートで前払いでき、ガスをハードコードしたコントラクトが壊れるのを避けられます。\n- 固定量のガスを転送するコントラクトや、`transfer`/`send` の 2300 gas の stipend に依存するコントラクトは、呼び出された側の最初のストレージ読み取りに 2100 かかるようになったため壊れる可能性があります。ガス量のハードコードは避けてください。\n- warm/cold モデルは、後の変更の土台になっています。[EIP-3651](/eip-3651/) はブロックの `COINBASE` を事前に warm にし、払い戻しのルールは [EIP-3529](/eip-3529/) で見直されました。\n- 同じスロットを繰り返し読むのは安価になりました。ガスがかかるのは、多数の異なるスロットやコントラクトを読む場合です。\n"},"ko":{"lang":"ko","tldr":"warm과 cold 상태 접근을 도입했다. 트랜잭션에서 주소나 스토리지 슬롯을 처음 건드리면 2600 또는 2100 gas, 이후에는 100 gas가 들어, 오랜 DoS 벡터를 막았다.","tags":["gas","evm","state","access-lists","berlin"],"related":[2930,1884,2200,3529,3651],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2929/","markdown":"## 어떤 문제를 해결하나요?\n\n`SLOAD`, `BALANCE`, `EXTCODESIZE`, `CALL` 계열처럼 상태를 읽는 opcode는 노드가 디스크에서 데이터를 가져오게 만들 수 있습니다. 이들은 수년간 가격이 너무 낮게 매겨져 있었습니다. 저자들은 일부러 IO를 많이 쓰게 만든 트랜잭션을 처리하는 데 20~80초가 걸렸다(평균 트랜잭션은 밀리초)는 연구를 인용합니다.\n\n모든 가격을 그냥 올리면, 같은 데이터를 반복해서 읽는 컨트랙트까지 불이익을 받습니다. 두 번째 읽기는 캐시에 적중하는데도 말입니다. EIP-2929는 트랜잭션에서 무언가를 **처음** 건드릴 때만 비싼 가격을 매깁니다. Berlin 업그레이드(2021년 4월)에서 적용되었습니다.\n\n## 어떻게 동작하나요?\n\n각 트랜잭션 동안 클라이언트는 두 개의 집합을 유지합니다.\n\n- `accessed_addresses`: 발신자, `tx.to`(또는 생성된 컨트랙트), 모든 프리컴파일로 미리 채워 둡니다.\n- `accessed_storage_keys`: `(address, slot)` 쌍의 집합으로, 비어 있는 상태로 시작합니다.\n\n| 상수 | 가스 |\n| --- | --- |\n| `COLD_ACCOUNT_ACCESS_COST` | 2600 |\n| `COLD_SLOAD_COST` | 2100 |\n| `WARM_STORAGE_READ_COST` | 100 |\n\n- **계정 접근**(`BALANCE`, `EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`, `CALL`, `CALLCODE`, `DELEGATECALL`, `STATICCALL`): 주소가 cold이면 2600(그 후 warm으로 표시), 아니면 100. 호출의 경우 63/64 가스 전달 규칙보다 먼저 부과됩니다.\n- **`SLOAD`**: 슬롯이 cold이면 2100, 아니면 100.\n- **`SSTORE`**: 슬롯이 cold이면 2100을 추가합니다. [EIP-2200](/eip-2200/)의 파라미터가 조정되어(`SLOAD_GAS`는 100, `SSTORE_RESET_GAS`는 `5000 - 2100`이 됨) cold read-modify-write 비용은 이전과 거의 같습니다.\n- **`SELFDESTRUCT`**: 수혜자가 cold이면 2600을 추가합니다.\n- `CREATE`/`CREATE2`는 새 주소를 즉시 warm으로 만듭니다.\n- 호출 프레임이 revert되면 warm 집합은 그 프레임 이전 상태로 롤백됩니다.\n\n## 샘플 코드\n\n한 트랜잭션 안에서 cold 읽기와 warm 읽기의 가스 차이:\n\n```solidity\ncontract WarmCold {\n    uint256 public x = 1;\n\n    function readTwice() external view returns (uint256 cold, uint256 warm) {\n        uint256 g = gasleft();\n        uint256 a = x;               // first SLOAD of this slot: cold (2100)\n        cold = g - gasleft();\n        g = gasleft();\n        uint256 b = x;               // same slot again: warm (100)\n        warm = g - gasleft();\n        require(a == b);\n    }\n}\n```\n\n(측정값에는 약간의 오버헤드가 포함되며, 옵티마이저가 두 읽기를 합칠 수도 있습니다.)\n\n액세스 리스트([EIP-2930](/eip-2930/))로 미리 warm 만들기, ethers v6:\n\n```ts\nconst tx = await wallet.sendTransaction({\n  to: token,\n  data,\n  accessList: [{ address: token, storageKeys: [balanceSlot] }],\n});\n```\n\n## 알아둘 점\n\n- **상태: Final**이며, [EIP-2930](/eip-2930/) 액세스 리스트와 함께 Berlin에서 활성화되었습니다. 액세스 리스트를 쓰면 트랜잭션이 주소와 슬롯을 미리 선언해 약간 낮은 요율로 선불할 수 있고, 가스를 하드코딩한 컨트랙트가 깨지는 것을 피할 수 있습니다.\n- 고정된 양의 가스를 전달하거나 `transfer`/`send`의 2300 gas stipend에 의존하는 컨트랙트는, 피호출자의 첫 스토리지 읽기가 이제 2100이 들기 때문에 깨질 수 있습니다. 가스량 하드코딩은 피하세요.\n- warm/cold 모델은 이후 변경의 토대입니다. [EIP-3651](/eip-3651/)은 블록의 `COINBASE`를 미리 warm으로 만들고, 환불 규칙은 [EIP-3529](/eip-3529/)에서 개정되었습니다.\n- 같은 슬롯을 반복해서 읽는 것은 이제 저렴합니다. 가스가 드는 것은 서로 다른 슬롯이나 컨트랙트를 많이 읽는 경우입니다.\n"},"zh":{"lang":"zh","tldr":"引入 warm 与 cold 状态访问：交易中首次访问某个地址或存储槽需 2600 或 2100 gas，之后的访问只需 100，堵住了一个长期存在的 DoS 攻击面。","tags":["gas","evm","state","access-lists","berlin"],"related":[2930,1884,2200,3529,3651],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2929/","markdown":"## 它解决什么问题？\n\n读取状态的 opcode，如 `SLOAD`、`BALANCE`、`EXTCODESIZE` 和 `CALL` 系列，可能迫使节点从磁盘获取数据。多年来它们的定价一直偏低。作者引用的研究显示，刻意构造的 IO 密集型交易需要 20 到 80 秒来处理，而一般交易只需几毫秒。\n\n简单地提高所有价格，会惩罚那些反复读取同一数据的合约，尽管第二次读取会命中缓存。EIP-2929 只在交易中**第一次**访问某项内容时收取高价。它随 Berlin 升级（2021 年 4 月）上线。\n\n## 它如何运作\n\n在每笔交易期间，客户端维护两个集合：\n\n- `accessed_addresses`，预先填入发送者、`tx.to`（或被创建的合约）以及所有预编译合约；\n- `accessed_storage_keys`，由 `(address, slot)` 对组成的集合，初始为空。\n\n| 常量 | Gas |\n| --- | --- |\n| `COLD_ACCOUNT_ACCESS_COST` | 2600 |\n| `COLD_SLOAD_COST` | 2100 |\n| `WARM_STORAGE_READ_COST` | 100 |\n\n- **账户访问**（`BALANCE`、`EXTCODESIZE`、`EXTCODECOPY`、`EXTCODEHASH`、`CALL`、`CALLCODE`、`DELEGATECALL`、`STATICCALL`）：如果地址是 cold，则为 2600（随后将其标记为 warm），否则为 100。对于调用，这笔费用在 63/64 gas 转发规则之前收取。\n- **`SLOAD`**：如果槽是 cold 则为 2100，否则为 100。\n- **`SSTORE`**：如果槽是 cold，则额外增加 2100。[EIP-2200](/eip-2200/) 的参数相应调整（`SLOAD_GAS` 变为 100，`SSTORE_RESET_GAS` 变为 `5000 - 2100`），因此 cold 的读-改-写成本与之前大致相同。\n- **`SELFDESTRUCT`**：如果受益人是 cold，则额外增加 2600。\n- `CREATE`/`CREATE2` 会立即把新地址变为 warm。\n- 如果某个调用帧发生 revert，warm 集合会回滚到该帧之前的状态。\n\n## 示例代码\n\n同一笔交易中 cold 与 warm 读取的 gas 差异：\n\n```solidity\ncontract WarmCold {\n    uint256 public x = 1;\n\n    function readTwice() external view returns (uint256 cold, uint256 warm) {\n        uint256 g = gasleft();\n        uint256 a = x;               // first SLOAD of this slot: cold (2100)\n        cold = g - gasleft();\n        g = gasleft();\n        uint256 b = x;               // same slot again: warm (100)\n        warm = g - gasleft();\n        require(a == b);\n    }\n}\n```\n\n（测得的数字包含少量开销，并且优化器可能会合并这两次读取。）\n\n使用访问列表（[EIP-2930](/eip-2930/)）预热，ethers v6：\n\n```ts\nconst tx = await wallet.sendTransaction({\n  to: token,\n  data,\n  accessList: [{ address: token, storageKeys: [balanceSlot] }],\n});\n```\n\n## 需要注意\n\n- **状态：Final**，与 [EIP-2930](/eip-2930/) 访问列表一同在 Berlin 激活。访问列表允许交易预先声明地址和槽，以略低的费率预先支付，并避免破坏硬编码 gas 的合约。\n- 转发固定数量 gas 的合约，或依赖 `transfer`/`send` 的 2300 gas stipend 的合约，可能会因为被调用方的首次存储读取现在要 2100 而出问题。请避免硬编码 gas 数量。\n- warm/cold 模型是后续变更的基础：[EIP-3651](/eip-3651/) 预热区块的 `COINBASE`，退款规则则在 [EIP-3529](/eip-3529/) 中修订。\n- 反复读取同一个槽现在很便宜；读取许多不同的槽或合约才是花费 gas 的地方。\n"}},"requiredBy":[2330,2780,2930,3529,3584,3651,3978,5027,5065,5081,5478,5920,6046,6188,6189,6190,6780,6810,7069,7519,7620,7650,7702,7791,7906,7907,8057,8125,8164,8289,8295,8296,8358,8374,8397]}
