{"eip":2937,"title":"SET_INDESTRUCTIBLE opcode","description":"Add a SETINDESTRUCTIBLE (0xA8) opcode that prevents the contract from calling SELFDESTRUCT (0xFF).","authors":["Vitalik Buterin (@vbuterin)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2020-09-04","discussionsTo":"https://ethereum-magicians.org/t/eip-2937-set-indestructible/4571","repo":"EIPs","label":"EIP-2937","officialUrl":"https://eips.ethereum.org/EIPS/eip-2937","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2937.md","url":"https://eips.huatuo.xyz/eip-2937/","tldr":{"en":"A stagnant proposal for a SET_INDESTRUCTIBLE opcode (0xA8) that lets a contract permanently opt out of SELFDESTRUCT, so libraries can guarantee their code will never disappear.","ja":"コントラクトが SELFDESTRUCT を恒久的に無効化できる SET_INDESTRUCTIBLE オペコード（0xA8）の、停滞中の提案。ライブラリは、自分のコードが決して消えないことを保証できる。","ko":"컨트랙트가 SELFDESTRUCT를 영구히 거부할 수 있게 하는 SET_INDESTRUCTIBLE 오퍼코드(0xA8)에 대한, 정체된 제안. 라이브러리가 자신의 코드가 절대 사라지지 않음을 보장할 수 있다.","zh":"一项已停滞的提案：新增 SET_INDESTRUCTIBLE 操作码（0xA8），让合约永久退出 SELFDESTRUCT，使库合约可以保证自己的代码永远不会消失。"},"tags":["core","evm","opcode","selfdestruct","stagnant"],"explainers":{"en":{"lang":"en","tldr":"A stagnant proposal for a SET_INDESTRUCTIBLE opcode (0xA8) that lets a contract permanently opt out of SELFDESTRUCT, so libraries can guarantee their code will never disappear.","tags":["core","evm","opcode","selfdestruct","stagnant"],"related":[6780,6049,4758],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2937/","markdown":"## What problem does it solve?\n\nWhen this was written, any contract containing a reachable `SELFDESTRUCT` (directly, or through a `DELEGATECALL` into code that self-destructs) could wipe its own code. That is a problem for anything that other contracts depend on:\n\n- A shared library called via `DELEGATECALL` could vanish, bricking every contract that uses it.\n- Account-abstraction designs want wallets to rely on code that will \"exist unmodified forever\".\n\nAuditing that no path leads to `SELFDESTRUCT` is error-prone. EIP-2937 offers a simple, verifiable promise instead: put one opcode at the very start of your code and self-destruction becomes impossible. Unlike proposals that disable `SELFDESTRUCT` for everyone, it changes nothing for existing contracts.\n\n## How it works\n\n- A new transaction-wide set `globals.indestructible` is added, starting empty (it works like the existing set of self-destructed accounts).\n- New opcode `SET_INDESTRUCTIBLE` at `0xA8`, costing `G_base` (2 gas), adds the current executing account (`callee`) to that set.\n- If `SELFDESTRUCT` runs while the current `callee` is in the set, it throws an exception.\n\nThe intended pattern is that the **first byte** of the contract's code is `0xA8`, so every execution marks it indestructible before anything else happens.\n\nA global set is used rather than a per-frame flag because a local flag could be bypassed: the contract could `DELEGATECALL` into other code that then self-destructs in the contract's context.\n\n## Sample code\n\nIllustrative bytecode for a contract whose runtime begins with the proposed opcode (`0xA8` is not assigned on mainnet):\n\n```text\nA8          SET_INDESTRUCTIBLE   ; mark this account for the rest of the tx\n60 00       PUSH1 0x00\n35          CALLDATALOAD\n...                              ; normal contract logic\n33          CALLER\nFF          SELFDESTRUCT         ; would now throw instead of deleting the code\n```\n\nPseudocode of the rule:\n\n```python\ndef op_set_indestructible(ctx):\n    ctx.tx.indestructible.add(ctx.callee)\n\ndef op_selfdestruct(ctx, beneficiary):\n    if ctx.callee in ctx.tx.indestructible:\n        raise ExceptionalHalt(\"indestructible\")\n    ...  # usual SELFDESTRUCT behaviour\n```\n\n## Things to know\n\n- Status: **Stagnant**. It was never adopted.\n- Ethereum instead neutralised `SELFDESTRUCT` for everyone: since the Cancun upgrade, [EIP-6780](/eip-6780/) only deletes code when the contract was created in the same transaction. In other cases it just sends the ETH balance. Deprecation was signalled in [EIP-6049](/eip-6049/), and [EIP-4758](/eip-4758/) proposed turning it into `SENDALL`.\n- The spec notes that if `SELFDESTRUCT` is removed, this opcode simply becomes a no-op. It also notes a tension with state-rent schemes that would delete old contracts.\n"},"ja":{"lang":"ja","tldr":"コントラクトが SELFDESTRUCT を恒久的に無効化できる SET_INDESTRUCTIBLE オペコード（0xA8）の、停滞中の提案。ライブラリは、自分のコードが決して消えないことを保証できる。","tags":["core","evm","opcode","selfdestruct","stagnant"],"related":[6780,6049,4758],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2937/","markdown":"## 何を解決するのか\n\nこの提案が書かれた当時、到達可能な `SELFDESTRUCT` を含むコントラクト（直接、または自己破壊するコードへの `DELEGATECALL` を通じて）は、自分自身のコードを消せました。他のコントラクトが依存するものにとって、これは問題です。\n\n- `DELEGATECALL` で呼び出される共有ライブラリが消えると、それを使うすべてのコントラクトが使用不能になります。\n- アカウント抽象化の設計では、ウォレットが「永遠に変更されずに存在する」コードに頼れることを求めています。\n\n`SELFDESTRUCT` に至る経路がないことを監査するのは、ミスが起きやすい作業です。EIP-2937 は代わりに、単純で検証可能な約束を提供します。コードの先頭にオペコードを 1 つ置けば、自己破壊は不可能になります。`SELFDESTRUCT` をすべての人に対して無効にする提案とは違い、既存のコントラクトには何も変更を加えません。\n\n## 仕組み\n\n- トランザクション全体で共有される新しい集合 `globals.indestructible` が追加され、空の状態から始まります（既存の自己破壊済みアカウントの集合と同じように機能します）。\n- 新しいオペコード `SET_INDESTRUCTIBLE` が `0xA8` に追加され、コストは `G_base`（2 ガス）で、現在実行中のアカウント（`callee`）をその集合に追加します。\n- `SELFDESTRUCT` が実行されたとき、現在の `callee` がその集合に含まれていれば、例外がスローされます。\n\n想定されているパターンは、コントラクトのコードの**先頭バイト**を `0xA8` にすることで、何かが起きる前にあらゆる実行がそれを破壊不能としてマークします。\n\nフレームごとのフラグではなくグローバルな集合を使うのは、ローカルなフラグは迂回できるからです。コントラクトが他のコードに `DELEGATECALL` し、そのコードがコントラクトのコンテキストで自己破壊できてしまいます。\n\n## サンプルコード\n\nランタイムが提案されたオペコードで始まるコントラクトの、説明用バイトコード（`0xA8` はメインネットでは割り当てられていません）:\n\n```text\nA8          SET_INDESTRUCTIBLE   ; mark this account for the rest of the tx\n60 00       PUSH1 0x00\n35          CALLDATALOAD\n...                              ; normal contract logic\n33          CALLER\nFF          SELFDESTRUCT         ; would now throw instead of deleting the code\n```\n\nルールの擬似コード:\n\n```python\ndef op_set_indestructible(ctx):\n    ctx.tx.indestructible.add(ctx.callee)\n\ndef op_selfdestruct(ctx, beneficiary):\n    if ctx.callee in ctx.tx.indestructible:\n        raise ExceptionalHalt(\"indestructible\")\n    ...  # usual SELFDESTRUCT behaviour\n```\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。採用されたことはありません。\n- Ethereum は代わりに、`SELFDESTRUCT` をすべての人に対して無力化しました。Cancun アップグレード以降、[EIP-6780](/eip-6780/) はコントラクトが同じトランザクション内で作成された場合にのみコードを削除します。それ以外の場合は ETH 残高を送るだけです。非推奨化は [EIP-6049](/eip-6049/) で示され、[EIP-4758](/eip-4758/) はそれを `SENDALL` に置き換えることを提案しました。\n- 仕様は、`SELFDESTRUCT` が削除されれば、このオペコードは単なる no-op になると述べています。また、古いコントラクトを削除するステートレントの方式との緊張関係にも触れています。\n"},"ko":{"lang":"ko","tldr":"컨트랙트가 SELFDESTRUCT를 영구히 거부할 수 있게 하는 SET_INDESTRUCTIBLE 오퍼코드(0xA8)에 대한, 정체된 제안. 라이브러리가 자신의 코드가 절대 사라지지 않음을 보장할 수 있다.","tags":["core","evm","opcode","selfdestruct","stagnant"],"related":[6780,6049,4758],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2937/","markdown":"## 어떤 문제를 해결하나요?\n\n이 제안이 작성될 당시에는 도달 가능한 `SELFDESTRUCT`를 포함한 컨트랙트(직접, 또는 자기 파괴하는 코드로의 `DELEGATECALL`을 통해)가 자기 코드를 지울 수 있었습니다. 다른 컨트랙트가 의존하는 것에는 이것이 문제입니다.\n\n- `DELEGATECALL`로 호출되는 공유 라이브러리가 사라지면 이를 쓰는 모든 컨트랙트가 먹통이 됩니다.\n- 계정 추상화 설계에서는 지갑이 \"영원히 변경 없이 존재하는\" 코드에 의존하기를 바랍니다.\n\n`SELFDESTRUCT`로 이어지는 경로가 없음을 감사하는 일은 실수하기 쉽습니다. EIP-2937은 대신 단순하고 검증 가능한 약속을 제공합니다. 코드 맨 앞에 오퍼코드 하나를 두면 자기 파괴가 불가능해집니다. 모두에게 `SELFDESTRUCT`를 비활성화하는 제안과 달리, 기존 컨트랙트에는 아무것도 바꾸지 않습니다.\n\n## 어떻게 동작하나요?\n\n- 트랜잭션 전체에 걸친 새 집합 `globals.indestructible`이 추가되며 비어 있는 상태에서 시작합니다(기존의 자기 파괴된 계정 집합과 같은 방식으로 동작합니다).\n- 새 오퍼코드 `SET_INDESTRUCTIBLE`이 `0xA8`에 추가되며 비용은 `G_base`(2 가스)이고, 현재 실행 중인 계정(`callee`)을 그 집합에 추가합니다.\n- 현재 `callee`가 그 집합에 있을 때 `SELFDESTRUCT`가 실행되면 예외가 발생합니다.\n\n의도된 패턴은 컨트랙트 코드의 **첫 바이트**를 `0xA8`로 두는 것이며, 그러면 모든 실행이 다른 일이 일어나기 전에 이를 파괴 불가로 표시합니다.\n\n프레임별 플래그가 아니라 전역 집합을 쓰는 이유는 로컬 플래그는 우회할 수 있기 때문입니다. 컨트랙트가 다른 코드로 `DELEGATECALL`하면 그 코드가 컨트랙트의 컨텍스트에서 자기 파괴를 할 수 있습니다.\n\n## 샘플 코드\n\n런타임이 제안된 오퍼코드로 시작하는 컨트랙트의 설명용 바이트코드(`0xA8`은 메인넷에 할당되어 있지 않습니다):\n\n```text\nA8          SET_INDESTRUCTIBLE   ; mark this account for the rest of the tx\n60 00       PUSH1 0x00\n35          CALLDATALOAD\n...                              ; normal contract logic\n33          CALLER\nFF          SELFDESTRUCT         ; would now throw instead of deleting the code\n```\n\n규칙의 의사 코드:\n\n```python\ndef op_set_indestructible(ctx):\n    ctx.tx.indestructible.add(ctx.callee)\n\ndef op_selfdestruct(ctx, beneficiary):\n    if ctx.callee in ctx.tx.indestructible:\n        raise ExceptionalHalt(\"indestructible\")\n    ...  # usual SELFDESTRUCT behaviour\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 채택된 적이 없습니다.\n- 이더리움은 대신 모두에게 `SELFDESTRUCT`를 무력화했습니다. Cancun 업그레이드 이후 [EIP-6780](/eip-6780/)은 컨트랙트가 같은 트랜잭션에서 생성된 경우에만 코드를 삭제합니다. 그 외의 경우에는 ETH 잔액만 보냅니다. 폐기 예고는 [EIP-6049](/eip-6049/)에서 이루어졌고, [EIP-4758](/eip-4758/)은 이를 `SENDALL`로 바꾸자고 제안했습니다.\n- 명세는 `SELFDESTRUCT`가 제거되면 이 오퍼코드는 그냥 no-op이 된다고 언급합니다. 또한 오래된 컨트랙트를 삭제할 상태 렌트 방안과의 긴장 관계도 언급합니다.\n"},"zh":{"lang":"zh","tldr":"一项已停滞的提案：新增 SET_INDESTRUCTIBLE 操作码（0xA8），让合约永久退出 SELFDESTRUCT，使库合约可以保证自己的代码永远不会消失。","tags":["core","evm","opcode","selfdestruct","stagnant"],"related":[6780,6049,4758],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2937/","markdown":"## 它解决什么问题？\n\n在撰写该提案时，任何包含可达 `SELFDESTRUCT` 的合约（无论是直接包含，还是通过 `DELEGATECALL` 进入会自毁的代码）都可以抹掉自己的代码。对于被其他合约所依赖的任何东西，这都是个问题：\n\n- 通过 `DELEGATECALL` 调用的共享库可能消失，导致所有使用它的合约瘫痪。\n- 账户抽象的设计希望钱包依赖那些\"永远原样存在\"的代码。\n\n审计\"没有任何路径通向 `SELFDESTRUCT`\"很容易出错。EIP-2937 则提供了一个简单、可验证的承诺：在代码的最开头放一个操作码，自毁就不可能发生。与为所有人禁用 `SELFDESTRUCT` 的提案不同，它对现有合约没有任何改变。\n\n## 它如何运作\n\n- 新增一个交易范围内的全局集合 `globals.indestructible`，初始为空（其工作方式与现有的已自毁账户集合类似）。\n- 新操作码 `SET_INDESTRUCTIBLE`，位于 `0xA8`，花费 `G_base`（2 gas），把当前正在执行的账户（`callee`）加入该集合。\n- 如果在当前 `callee` 位于该集合中时执行 `SELFDESTRUCT`，则抛出异常。\n\n预期的用法是让合约代码的**第一个字节**为 `0xA8`，这样每次执行都会在任何其他事情发生之前把它标记为不可销毁。\n\n这里使用全局集合而不是每个调用帧的标志，是因为本地标志可以被绕过：合约可以 `DELEGATECALL` 进入其他代码，而该代码随后在合约的上下文中自毁。\n\n## 示例代码\n\n一个运行时代码以该提议操作码开头的合约的示意字节码（`0xA8` 在主网上并未分配）：\n\n```text\nA8          SET_INDESTRUCTIBLE   ; mark this account for the rest of the tx\n60 00       PUSH1 0x00\n35          CALLDATALOAD\n...                              ; normal contract logic\n33          CALLER\nFF          SELFDESTRUCT         ; would now throw instead of deleting the code\n```\n\n该规则的伪代码：\n\n```python\ndef op_set_indestructible(ctx):\n    ctx.tx.indestructible.add(ctx.callee)\n\ndef op_selfdestruct(ctx, beneficiary):\n    if ctx.callee in ctx.tx.indestructible:\n        raise ExceptionalHalt(\"indestructible\")\n    ...  # usual SELFDESTRUCT behaviour\n```\n\n## 需要注意\n\n- 状态：**Stagnant**。它从未被采纳。\n- 以太坊转而让 `SELFDESTRUCT` 对所有人失效：自 Cancun 升级起，[EIP-6780](/eip-6780/) 仅在合约于同一笔交易中创建时才删除代码；其他情况下只是转出 ETH 余额。弃用在 [EIP-6049](/eip-6049/) 中已有预告，[EIP-4758](/eip-4758/) 则提议把它改为 `SENDALL`。\n- 规范指出，如果 `SELFDESTRUCT` 被移除，这个操作码就只是一个空操作。它还指出了与会删除旧合约的状态租金方案之间的矛盾。\n"}}}
