{"eip":6780,"title":"SELFDESTRUCT only in same transaction","description":"SELFDESTRUCT will recover all funds to the target but not delete the account, except when called in the same transaction as creation","authors":["Guillaume Ballet (@gballet)","Vitalik Buterin (@vbuterin)","Dankrad Feist (@dankrad)"],"status":"Final","type":"Standards Track","category":"Core","created":"2023-03-25","requires":[2681,2929,3529],"discussionsTo":"https://ethereum-magicians.org/t/deactivate-selfdestruct-except-where-it-occurs-in-the-same-transaction-in-which-a-contract-was-created/13539","repo":"EIPs","label":"EIP-6780","officialUrl":"https://eips.ethereum.org/EIPS/eip-6780","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6780.md","url":"https://eips.huatuo.xyz/eip-6780/","tldr":{"en":"Neuters SELFDESTRUCT: it now only sends the contract's ETH to a target and no longer deletes code or storage, unless the contract was created in the same transaction.","ja":"SELFDESTRUCT を骨抜きにする。コントラクトの ETH をターゲットに送るだけで、コードやストレージはもう削除しない。ただし同じトランザクション内で作成されたコントラクトは例外。","ko":"SELFDESTRUCT를 무력화한다. 이제 컨트랙트의 ETH를 대상에게 보낼 뿐 코드나 스토리지를 더 이상 삭제하지 않는다. 단, 같은 트랜잭션에서 생성된 컨트랙트는 예외다.","zh":"削弱 SELFDESTRUCT：它现在只会把合约的 ETH 发送给目标地址，不再删除代码或存储，除非该合约是在同一笔交易中创建的。"},"tags":["evm","opcode","selfdestruct","cancun","state"],"explainers":{"en":{"lang":"en","tldr":"Neuters SELFDESTRUCT: it now only sends the contract's ETH to a target and no longer deletes code or storage, unless the contract was created in the same transaction.","tags":["evm","opcode","selfdestruct","cancun","state"],"related":[6049,3529,2929,2535,5656],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-6780/","markdown":"## What problem does it solve?\n\n`SELFDESTRUCT` used to wipe an account completely: its code, every storage slot and the account itself, sending the balance to a chosen address. That is a large, unbounded state change, and it would be very hard to support in future state designs such as Verkle trees, where one account's data is spread across many unrelated keys.\n\nThe opcode was already deprecated by [EIP-6049](/eip-6049/). EIP-6780 removes the destructive part while keeping the two common, harmless uses working: pulling all ETH out of a contract, and creating and destroying a contract within a single transaction.\n\n## How it works\n\nThe behaviour now depends on whether the contract was created **in the current transaction**.\n\n**Contract created in an earlier transaction (the normal case):**\n\n- The current execution frame halts.\n- The entire balance is transferred to the target.\n- Code, storage, nonce and the account itself are **not** deleted.\n- If the target is the contract itself, nothing changes; ETH is no longer burned.\n\n**Contract created earlier in the same transaction:**\n\n- The old behaviour applies: balance sent to the target, the account and all its data deleted.\n- If the target is the contract itself, that ETH is burned, as before.\n\n\"Created\" means from the start of a contract-creation transaction or when a `CREATE` / `CREATE2` begins executing, even if the address already had a balance. Gas rules from [EIP-2929](/eip-2929/) are unchanged and there is still no refund (removed by [EIP-3529](/eip-3529/)).\n\n## Sample code\n\nPseudocode for the new opcode logic:\n\n```python\ndef selfdestruct(account, target):\n    balance = state.get_balance(account)\n    state.add_balance(target, balance)\n    state.sub_balance(account, balance)        # net zero if target == account\n\n    if account in tx.created_accounts:         # created in this same transaction\n        state.set_balance(account, 0)          # burns ETH if target == account\n        tx.accounts_to_delete.add(account)     # old behaviour: wipe code + storage\n    halt_frame()\n```\n\nA pattern that **no longer works** – metamorphic upgrades via `CREATE2`:\n\n```solidity\n// Before Cancun: selfdestruct, then CREATE2 new code at the same address.\n// After EIP-6780: selfdestruct leaves the code in place, so the second\n// CREATE2 to that address fails because the account already has code.\nfunction kill() external {\n    require(msg.sender == owner);\n    selfdestruct(payable(owner)); // now only moves the ETH out\n}\n```\n\n## Things to know\n\n- **Status: Final.** Activated on mainnet in the Cancun/Deneb (\"Dencun\") upgrade, together with [EIP-5656](/eip-5656/) `MCOPY`.\n- Upgrade schemes based on `SELFDESTRUCT` + `CREATE2` redeployment are broken. Use proxy patterns such as [ERC-2535](/eip-2535/) or standard upgradeable proxies.\n- Contracts that relied on self-targeted `SELFDESTRUCT` to burn ETH no longer burn it unless created in the same transaction.\n- `SELFDESTRUCT` is still deprecated. Solidity emits a warning for it and future upgrades may reduce its functionality further, so do not use it in new code.\n"},"ja":{"lang":"ja","tldr":"SELFDESTRUCT を骨抜きにする。コントラクトの ETH をターゲットに送るだけで、コードやストレージはもう削除しない。ただし同じトランザクション内で作成されたコントラクトは例外。","tags":["evm","opcode","selfdestruct","cancun","state"],"related":[6049,3529,2929,2535,5656],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-6780/","markdown":"## 何を解決するのか\n\n`SELFDESTRUCT` はかつて、アカウントのコード、すべてのストレージスロット、アカウント自体を完全に消去し、残高を指定したアドレスへ送っていました。これは大きく上限のない状態変更であり、1 つのアカウントのデータが無関係な多数のキーに分散される Verkle ツリーのような将来のステート設計では、サポートするのが非常に困難です。\n\nこのオペコードはすでに [EIP-6049](/eip-6049/) で非推奨になっていました。EIP-6780 は破壊的な部分を取り除きつつ、無害でよく使われる 2 つの用途、つまりコントラクトからすべての ETH を引き出すことと、1 つのトランザクション内でコントラクトを作成して破棄することを引き続き動作させます。\n\n## 仕組み\n\n動作は、そのコントラクトが**現在のトランザクション内で作成されたか**どうかで決まります。\n\n**以前のトランザクションで作成されたコントラクト（通常のケース）:**\n\n- 現在の実行フレームが停止します。\n- 残高のすべてがターゲットに転送されます。\n- コード、ストレージ、nonce、アカウント自体は削除**されません**。\n- ターゲットがコントラクト自身の場合は何も変わらず、ETH はもうバーンされません。\n\n**同じトランザクション内で先に作成されたコントラクト:**\n\n- 従来の動作が適用されます。残高がターゲットに送られ、アカウントとそのすべてのデータが削除されます。\n- ターゲットがコントラクト自身の場合、その ETH は従来どおりバーンされます。\n\n「作成された」とは、コントラクト作成トランザクションの開始時、または `CREATE` / `CREATE2` の実行開始時からを指し、そのアドレスにすでに残高があった場合でも同様です。[EIP-2929](/eip-2929/) のガスルールは変わらず、返金も引き続きありません（[EIP-3529](/eip-3529/) で廃止）。\n\n## サンプルコード\n\n新しいオペコードのロジックの擬似コード:\n\n```python\ndef selfdestruct(account, target):\n    balance = state.get_balance(account)\n    state.add_balance(target, balance)\n    state.sub_balance(account, balance)        # net zero if target == account\n\n    if account in tx.created_accounts:         # created in this same transaction\n        state.set_balance(account, 0)          # burns ETH if target == account\n        tx.accounts_to_delete.add(account)     # old behaviour: wipe code + storage\n    halt_frame()\n```\n\n**もう動かなくなった**パターン – `CREATE2` によるメタモルフィックなアップグレード:\n\n```solidity\n// Before Cancun: selfdestruct, then CREATE2 new code at the same address.\n// After EIP-6780: selfdestruct leaves the code in place, so the second\n// CREATE2 to that address fails because the account already has code.\nfunction kill() external {\n    require(msg.sender == owner);\n    selfdestruct(payable(owner)); // now only moves the ETH out\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Final。** Cancun/Deneb（「Dencun」）アップグレードで [EIP-5656](/eip-5656/) の `MCOPY` とともにメインネットで有効化されました。\n- `SELFDESTRUCT` + `CREATE2` による再デプロイを使ったアップグレード方式は動作しなくなりました。[ERC-2535](/eip-2535/) や標準的なアップグレード可能プロキシなどのプロキシパターンを使ってください。\n- 自身を対象にした `SELFDESTRUCT` で ETH をバーンしていたコントラクトは、同じトランザクション内で作成されたものでない限り、もうバーンされません。\n- `SELFDESTRUCT` は依然として非推奨です。Solidity は警告を出し、今後のアップグレードで機能がさらに縮小される可能性があるため、新しいコードでは使わないでください。\n"},"ko":{"lang":"ko","tldr":"SELFDESTRUCT를 무력화한다. 이제 컨트랙트의 ETH를 대상에게 보낼 뿐 코드나 스토리지를 더 이상 삭제하지 않는다. 단, 같은 트랜잭션에서 생성된 컨트랙트는 예외다.","tags":["evm","opcode","selfdestruct","cancun","state"],"related":[6049,3529,2929,2535,5656],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-6780/","markdown":"## 어떤 문제를 해결하나요?\n\n`SELFDESTRUCT`는 예전에는 계정의 코드, 모든 스토리지 슬롯, 계정 자체를 완전히 지우고 잔액을 지정한 주소로 보냈습니다. 이는 크고 상한이 없는 상태 변경이어서, 한 계정의 데이터가 서로 무관한 여러 키에 흩어지는 Verkle 트리 같은 미래의 상태 설계에서는 지원하기가 매우 어렵습니다.\n\n이 opcode는 이미 [EIP-6049](/eip-6049/)에서 사용 중단(deprecated)되었습니다. EIP-6780은 파괴적인 부분을 없애면서도, 무해하고 흔히 쓰이는 두 가지 용도, 즉 컨트랙트에서 ETH를 전부 빼내는 것과 하나의 트랜잭션 안에서 컨트랙트를 만들고 파기하는 것은 계속 동작하게 합니다.\n\n## 어떻게 동작하나요?\n\n동작은 컨트랙트가 **현재 트랜잭션에서 생성되었는지**에 따라 달라집니다.\n\n**이전 트랜잭션에서 생성된 컨트랙트(일반적인 경우):**\n\n- 현재 실행 프레임이 중단됩니다.\n- 전체 잔액이 대상에게 전송됩니다.\n- 코드, 스토리지, nonce, 계정 자체는 삭제되지 **않습니다**.\n- 대상이 컨트랙트 자신이면 아무것도 바뀌지 않으며, ETH는 더 이상 소각되지 않습니다.\n\n**같은 트랜잭션에서 앞서 생성된 컨트랙트:**\n\n- 기존 동작이 적용됩니다. 잔액이 대상에게 전송되고 계정과 모든 데이터가 삭제됩니다.\n- 대상이 컨트랙트 자신이면 그 ETH는 이전처럼 소각됩니다.\n\n\"생성되었다\"는 것은 컨트랙트 생성 트랜잭션이 시작된 시점, 또는 `CREATE` / `CREATE2`가 실행을 시작한 시점부터를 뜻하며, 그 주소에 이미 잔액이 있었더라도 마찬가지입니다. [EIP-2929](/eip-2929/)의 gas 규칙은 그대로이고 환불도 여전히 없습니다([EIP-3529](/eip-3529/)에서 제거됨).\n\n## 샘플 코드\n\n새 opcode 로직의 의사 코드:\n\n```python\ndef selfdestruct(account, target):\n    balance = state.get_balance(account)\n    state.add_balance(target, balance)\n    state.sub_balance(account, balance)        # net zero if target == account\n\n    if account in tx.created_accounts:         # created in this same transaction\n        state.set_balance(account, 0)          # burns ETH if target == account\n        tx.accounts_to_delete.add(account)     # old behaviour: wipe code + storage\n    halt_frame()\n```\n\n더 이상 **동작하지 않는** 패턴 – `CREATE2`를 이용한 메타모픽 업그레이드:\n\n```solidity\n// Before Cancun: selfdestruct, then CREATE2 new code at the same address.\n// After EIP-6780: selfdestruct leaves the code in place, so the second\n// CREATE2 to that address fails because the account already has code.\nfunction kill() external {\n    require(msg.sender == owner);\n    selfdestruct(payable(owner)); // now only moves the ETH out\n}\n```\n\n## 알아둘 점\n\n- **상태: Final.** Cancun/Deneb(\"Dencun\") 업그레이드에서 [EIP-5656](/eip-5656/)의 `MCOPY`와 함께 메인넷에 활성화되었습니다.\n- `SELFDESTRUCT` + `CREATE2` 재배포에 기반한 업그레이드 방식은 더 이상 동작하지 않습니다. [ERC-2535](/eip-2535/)나 표준 업그레이드 가능 프록시 같은 프록시 패턴을 사용하세요.\n- 자기 자신을 대상으로 한 `SELFDESTRUCT`로 ETH를 소각하던 컨트랙트는 같은 트랜잭션에서 생성된 경우가 아니면 더 이상 소각하지 못합니다.\n- `SELFDESTRUCT`는 여전히 사용 중단 상태입니다. Solidity는 경고를 내보내며 향후 업그레이드에서 기능이 더 줄어들 수 있으므로 새 코드에서는 사용하지 마세요.\n"},"zh":{"lang":"zh","tldr":"削弱 SELFDESTRUCT：它现在只会把合约的 ETH 发送给目标地址，不再删除代码或存储，除非该合约是在同一笔交易中创建的。","tags":["evm","opcode","selfdestruct","cancun","state"],"related":[6049,3529,2929,2535,5656],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-6780/","markdown":"## 它解决什么问题？\n\n`SELFDESTRUCT` 过去会彻底清除一个账户：它的代码、每个存储槽以及账户本身，并把余额发送到指定地址。这是一个庞大且没有上限的状态变更，在 Verkle 树这类未来的状态设计中很难支持，因为一个账户的数据会分散在许多互不相关的键上。\n\n该操作码已经被 [EIP-6049](/eip-6049/) 弃用。EIP-6780 去掉了其破坏性的部分，同时保留了两种常见且无害的用法：从合约中取出全部 ETH，以及在单笔交易内创建并销毁合约。\n\n## 它如何运作\n\n现在的行为取决于合约是否**在当前交易中创建**。\n\n**合约创建于更早的交易（常规情况）：**\n\n- 当前执行帧停止。\n- 全部余额转给目标地址。\n- 代码、存储、nonce 和账户本身**不会**被删除。\n- 如果目标是合约自身，则没有任何变化；ETH 不再被销毁。\n\n**合约在同一笔交易中更早创建：**\n\n- 沿用旧行为：余额发送给目标地址，账户及其所有数据被删除。\n- 如果目标是合约自身，这部分 ETH 会像以前一样被销毁。\n\n\"创建\"指从合约创建交易开始时，或从 `CREATE` / `CREATE2` 开始执行时算起，即使该地址原本已有余额。[EIP-2929](/eip-2929/) 的 gas 规则不变，仍然没有退款（已被 [EIP-3529](/eip-3529/) 移除）。\n\n## 示例代码\n\n新操作码逻辑的伪代码：\n\n```python\ndef selfdestruct(account, target):\n    balance = state.get_balance(account)\n    state.add_balance(target, balance)\n    state.sub_balance(account, balance)        # net zero if target == account\n\n    if account in tx.created_accounts:         # created in this same transaction\n        state.set_balance(account, 0)          # burns ETH if target == account\n        tx.accounts_to_delete.add(account)     # old behaviour: wipe code + storage\n    halt_frame()\n```\n\n一个**不再有效**的模式 – 通过 `CREATE2` 实现的变形（metamorphic）升级：\n\n```solidity\n// Before Cancun: selfdestruct, then CREATE2 new code at the same address.\n// After EIP-6780: selfdestruct leaves the code in place, so the second\n// CREATE2 to that address fails because the account already has code.\nfunction kill() external {\n    require(msg.sender == owner);\n    selfdestruct(payable(owner)); // now only moves the ETH out\n}\n```\n\n## 需要注意\n\n- **状态：Final。** 已在 Cancun/Deneb（\"Dencun\"）升级中于主网激活，与 [EIP-5656](/eip-5656/) 的 `MCOPY` 一同上线。\n- 基于 `SELFDESTRUCT` + `CREATE2` 重新部署的升级方案已经失效。请使用代理模式，例如 [ERC-2535](/eip-2535/) 或标准的可升级代理。\n- 依赖针对自身的 `SELFDESTRUCT` 来销毁 ETH 的合约，除非是在同一笔交易中创建的，否则不再销毁 ETH。\n- `SELFDESTRUCT` 仍处于弃用状态。Solidity 会对其发出警告，未来的升级可能进一步削减其功能，因此不要在新代码中使用它。\n"}},"requiredBy":[2780,6800,7569,7708,8037,8246,8298]}
