{"eip":2970,"title":"IS_STATIC opcode","description":"Add a ISSTATIC (0x4A) opcode that pushes 1 if the current context is static (ie. the execution is in a STATICCALL or a descendant thereof, so state-changing operations are not possible), and 0 if it is not.","authors":["Vitalik Buterin (@vbuterin)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2020-09-13","discussionsTo":"https://ethereum-magicians.org/t/is-static-opcode-useful-for-aa/4609","repo":"EIPs","label":"EIP-2970","officialUrl":"https://eips.ethereum.org/EIPS/eip-2970","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2970.md","url":"https://eips.huatuo.xyz/eip-2970/","tldr":{"en":"Proposed an IS_STATIC opcode that tells a contract whether it is running inside a STATICCALL, so it can allow read-only calls while blocking state changes.","ja":"コントラクトが STATICCALL の内部で実行されているかどうかを判定できる IS_STATIC オペコードを提案した。読み取り専用の呼び出しは許可しつつ、ステート変更はブロックできるようにする。","ko":"컨트랙트가 STATICCALL 안에서 실행 중인지 알 수 있게 하는 IS_STATIC 옵코드를 제안했다. 읽기 전용 호출은 허용하면서 상태 변경은 막을 수 있게 한다.","zh":"提出了 IS_STATIC 操作码，让合约知道自己是否运行在 STATICCALL 之内，从而在允许只读调用的同时阻止状态变更。"},"tags":["evm","opcode","staticcall","account-abstraction","core"],"explainers":{"en":{"lang":"en","tldr":"Proposed an IS_STATIC opcode that tells a contract whether it is running inside a STATICCALL, so it can allow read-only calls while blocking state changes.","tags":["evm","opcode","staticcall","account-abstraction","core"],"related":[214,2938,7516],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2970/","markdown":"## What problem does it solve?\n\n[EIP-214](/eip-214/) added `STATICCALL`, which runs code in a context where any state change (storage writes, logs, value transfers, contract creation) causes a failure. Code running inside it, however, has no direct way to ask \"am I static right now?\".\n\nThat matters for account abstraction. Under [EIP-2938](/eip-2938/), a contract account might want to let outsiders make harmless read-only calls into it while rejecting anything that changes state. To do that, it needs to know whether the current context is static.\n\n## How it works\n\nThe proposal adds one opcode:\n\n- `IS_STATIC` at `0x4A` pushes `1` if the current execution is inside a `STATICCALL` (or anything called from one), and `0` otherwise.\n\nToday the only way to find out is a hack: make a small `CALL` to code that emits a `LOG` and exits. In a static context the `LOG` fails, so the call returns 0. The spec calls this fragile, because it depends on gas costs, and wasteful.\n\n## Sample code\n\nIllustrative only. `IS_STATIC` was never activated, so this is pseudocode for the proposed behaviour:\n\n```python\ndef op_is_static(evm):\n    evm.stack.push(1 if evm.message.is_static else 0)\n```\n\nThe workaround the EIP wants to replace, in Solidity:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract StaticProbe {\n    function emitLog() external {\n        require(msg.sender == address(this));\n        emit Probe();\n    }\n    event Probe();\n\n    // Returns true if called inside a STATICCALL. Costs gas and relies on\n    // LOG being forbidden in static context.\n    function isStatic() public returns (bool) {\n        (bool ok, ) = address(this).call{gas: 5000}(abi.encodeCall(this.emitLog, ()));\n        return !ok;\n    }\n}\n```\n\n## Things to know\n\n- Status is **Stagnant**. The abstract, backwards-compatibility and security sections were never filled in.\n- Opcode `0x4A` was later assigned to `BLOBBASEFEE` by [EIP-7516](/eip-7516/), so if this idea were revived it would need a different opcode number.\n- Its driving use case, [EIP-2938](/eip-2938/) account abstraction, also did not ship; later account-abstraction work took other routes.\n- The probe workaround above is sensitive to gas schedule changes; treat it as a demonstration, not production code.\n"},"ja":{"lang":"ja","tldr":"コントラクトが STATICCALL の内部で実行されているかどうかを判定できる IS_STATIC オペコードを提案した。読み取り専用の呼び出しは許可しつつ、ステート変更はブロックできるようにする。","tags":["evm","opcode","staticcall","account-abstraction","core"],"related":[214,2938,7516],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2970/","markdown":"## 何を解決するのか\n\n[EIP-214](/eip-214/) は `STATICCALL` を追加しました。これは、ステートの変更（ストレージ書き込み、ログ、value の送金、コントラクト作成）がすべて失敗になるコンテキストでコードを実行します。しかし、その内部で動くコードには「今、自分は static か？」と直接尋ねる手段がありません。\n\nこれはアカウント抽象化で問題になります。[EIP-2938](/eip-2938/) のもとでは、コントラクトアカウントは、外部の者による無害な読み取り専用の呼び出しを許可しつつ、ステートを変更するものは拒否したいかもしれません。そのためには、現在のコンテキストが static かどうかを知る必要があります。\n\n## 仕組み\n\nこの提案はオペコードを 1 つ追加します。\n\n- `0x4A` の `IS_STATIC` は、現在の実行が `STATICCALL`（またはそこから呼ばれたもの）の内部であれば `1`、そうでなければ `0` をプッシュします。\n\n現状でそれを知る唯一の方法はハックです。`LOG` を emit して終了するコードへ小さな `CALL` を行います。static コンテキストでは `LOG` が失敗するため、呼び出しは 0 を返します。仕様はこれを、ガスコストに依存していて壊れやすく、無駄が多いと述べています。\n\n## サンプルコード\n\n説明用です。`IS_STATIC` は有効化されなかったため、これは提案された挙動の疑似コードです。\n\n```python\ndef op_is_static(evm):\n    evm.stack.push(1 if evm.message.is_static else 0)\n```\n\nこの EIP が置き換えたい回避策（Solidity）:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract StaticProbe {\n    function emitLog() external {\n        require(msg.sender == address(this));\n        emit Probe();\n    }\n    event Probe();\n\n    // Returns true if called inside a STATICCALL. Costs gas and relies on\n    // LOG being forbidden in static context.\n    function isStatic() public returns (bool) {\n        (bool ok, ) = address(this).call{gas: 5000}(abi.encodeCall(this.emitLog, ()));\n        return !ok;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。abstract、後方互換性、セキュリティの各セクションは最後まで書かれませんでした。\n- オペコード `0x4A` は、その後 [EIP-7516](/eip-7516/) によって `BLOBBASEFEE` に割り当てられたため、このアイデアを復活させるなら別のオペコード番号が必要になります。\n- 動機となったユースケースである [EIP-2938](/eip-2938/) のアカウント抽象化も導入されませんでした。その後のアカウント抽象化の取り組みは別の道を取りました。\n- 上記のプローブによる回避策はガススケジュールの変更に敏感です。実演用であり、本番用コードとは見なさないでください。\n"},"ko":{"lang":"ko","tldr":"컨트랙트가 STATICCALL 안에서 실행 중인지 알 수 있게 하는 IS_STATIC 옵코드를 제안했다. 읽기 전용 호출은 허용하면서 상태 변경은 막을 수 있게 한다.","tags":["evm","opcode","staticcall","account-abstraction","core"],"related":[214,2938,7516],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2970/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-214](/eip-214/)는 `STATICCALL`을 추가했습니다. 상태 변경(스토리지 쓰기, 로그, 가치 전송, 컨트랙트 생성)이 일어나면 실패하는 컨텍스트에서 코드를 실행합니다. 하지만 그 안에서 실행되는 코드는 \"지금 내가 static인가?\"를 직접 물어볼 방법이 없습니다.\n\n이는 계정 추상화에서 중요합니다. [EIP-2938](/eip-2938/)에서는 컨트랙트 계정이 외부인의 무해한 읽기 전용 호출은 허용하되 상태를 바꾸는 것은 거부하고 싶을 수 있습니다. 그러려면 현재 컨텍스트가 static인지 알아야 합니다.\n\n## 어떻게 동작하나요?\n\n이 제안은 옵코드 하나를 추가합니다.\n\n- `0x4A`의 `IS_STATIC`은 현재 실행이 `STATICCALL`(또는 그 안에서 호출된 모든 것) 내부에 있으면 `1`을, 아니면 `0`을 푸시합니다.\n\n현재 이를 알아내는 유일한 방법은 편법입니다. `LOG`를 emit하고 종료하는 코드에 작은 `CALL`을 보냅니다. static 컨텍스트에서는 `LOG`가 실패하므로 호출은 0을 반환합니다. 스펙은 이를 가스 비용에 의존하므로 취약하고 낭비적이라고 평가합니다.\n\n## 샘플 코드\n\n설명용입니다. `IS_STATIC`은 활성화된 적이 없으므로 이는 제안된 동작에 대한 의사 코드입니다.\n\n```python\ndef op_is_static(evm):\n    evm.stack.push(1 if evm.message.is_static else 0)\n```\n\n이 EIP가 대체하려는 우회 방법(Solidity):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract StaticProbe {\n    function emitLog() external {\n        require(msg.sender == address(this));\n        emit Probe();\n    }\n    event Probe();\n\n    // Returns true if called inside a STATICCALL. Costs gas and relies on\n    // LOG being forbidden in static context.\n    function isStatic() public returns (bool) {\n        (bool ok, ) = address(this).call{gas: 5000}(abi.encodeCall(this.emitLog, ()));\n        return !ok;\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. abstract, 하위 호환성, 보안 섹션은 끝내 채워지지 않았습니다.\n- 옵코드 `0x4A`는 이후 [EIP-7516](/eip-7516/)에서 `BLOBBASEFEE`에 할당되었으므로, 이 아이디어를 되살린다면 다른 옵코드 번호가 필요합니다.\n- 이를 이끈 사용 사례인 [EIP-2938](/eip-2938/) 계정 추상화도 적용되지 않았습니다. 이후의 계정 추상화 작업은 다른 길을 택했습니다.\n- 위의 프로브 우회 방법은 가스 스케줄 변경에 민감합니다. 시연용일 뿐 프로덕션 코드로 취급하지 마세요.\n"},"zh":{"lang":"zh","tldr":"提出了 IS_STATIC 操作码，让合约知道自己是否运行在 STATICCALL 之内，从而在允许只读调用的同时阻止状态变更。","tags":["evm","opcode","staticcall","account-abstraction","core"],"related":[214,2938,7516],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2970/","markdown":"## 它解决什么问题？\n\n[EIP-214](/eip-214/) 添加了 `STATICCALL`，它在一个任何状态变更（存储写入、日志、转账、合约创建）都会导致失败的上下文中运行代码。然而，运行在其中的代码没有直接的办法询问\"我现在是静态的吗？\"。\n\n这对账户抽象很重要。在 [EIP-2938](/eip-2938/) 之下，合约账户可能希望允许外部对其发起无害的只读调用，同时拒绝任何会改变状态的调用。要做到这一点，它需要知道当前上下文是否为静态。\n\n## 它如何运作\n\n该提案新增一个操作码：\n\n- 位于 `0x4A` 的 `IS_STATIC`：如果当前执行位于 `STATICCALL`（或由其调用的任何东西）之内，则压入 `1`，否则压入 `0`。\n\n如今唯一的办法是一种 hack：向一段会发出 `LOG` 然后退出的代码发起一次小的 `CALL`。在静态上下文中 `LOG` 会失败，因此该调用返回 0。规范认为这种做法很脆弱（因为依赖 gas 成本）且浪费。\n\n## 示例代码\n\n仅作说明。`IS_STATIC` 从未被激活，因此这是对所提议行为的伪代码：\n\n```python\ndef op_is_static(evm):\n    evm.stack.push(1 if evm.message.is_static else 0)\n```\n\n该 EIP 想要取代的变通方案，用 Solidity 写成：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract StaticProbe {\n    function emitLog() external {\n        require(msg.sender == address(this));\n        emit Probe();\n    }\n    event Probe();\n\n    // Returns true if called inside a STATICCALL. Costs gas and relies on\n    // LOG being forbidden in static context.\n    function isStatic() public returns (bool) {\n        (bool ok, ) = address(this).call{gas: 5000}(abi.encodeCall(this.emitLog, ()));\n        return !ok;\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**。摘要、向后兼容性和安全性部分从未填写。\n- 操作码 `0x4A` 后来被 [EIP-7516](/eip-7516/) 分配给了 `BLOBBASEFEE`，所以如果重启这个想法，就需要另一个操作码编号。\n- 推动它的使用场景 [EIP-2938](/eip-2938/) 账户抽象同样没有上线；后来的账户抽象工作走了其他路线。\n- 上面的探测式变通方案对 gas 计价表的变化很敏感；请把它当作演示，而不是生产代码。\n"}}}
