{"eip":4758,"title":"Deactivate SELFDESTRUCT","description":"Deactivate SELFDESTRUCT by changing it to SENDALL, which does recover all funds to the caller but does not delete any code or storage.","authors":["Guillaume Ballet (@gballet)","Vitalik Buterin (@vbuterin)","Dankrad Feist (@dankrad)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2022-02-03","discussionsTo":"https://ethereum-magicians.org/t/eip-4758-deactivate-selfdestruct/8710","repo":"EIPs","label":"EIP-4758","officialUrl":"https://eips.ethereum.org/EIPS/eip-4758","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4758.md","url":"https://eips.huatuo.xyz/eip-4758/","tldr":{"en":"Proposed turning SELFDESTRUCT into SENDALL, which only sends the contract's ETH to the target and never deletes code or storage, to prepare Ethereum for Verkle trees and statelessness.","ja":"SELFDESTRUCT を SENDALL に変える提案。コントラクトの ETH を送るだけでコードやストレージは削除せず、Ethereum を Verkle ツリーとステートレス化に備えさせる。","ko":"SELFDESTRUCT를 SENDALL로 바꾸자는 제안. 컨트랙트의 ETH만 대상에게 보내고 코드나 스토리지는 절대 삭제하지 않아, 이더리움이 Verkle 트리와 무상태(statelessness)를 준비하게 한다.","zh":"建议把 SELFDESTRUCT 改为 SENDALL：只把合约的 ETH 发送给目标地址，永不删除代码或存储，为以太坊迈向 Verkle 树和无状态做准备。"},"tags":["evm","selfdestruct","opcodes","statelessness","core"],"explainers":{"en":{"lang":"en","tldr":"Proposed turning SELFDESTRUCT into SENDALL, which only sends the contract's ETH to the target and never deletes code or storage, to prepare Ethereum for Verkle trees and statelessness.","tags":["evm","selfdestruct","opcodes","statelessness","core"],"related":[6780,6049],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-4758/","markdown":"## What problem does it solve?\n\n`SELFDESTRUCT` wipes an account: its code, all of its storage, and its nonce. That is a large, unbounded state change. With Verkle trees, the data of one account is spread over many keys that are not obviously linked to the account root, so deleting \"everything belonging to this account\" becomes impractical.\n\nThe spec argues there are no strong reasons left to use `SELFDESTRUCT`, and that disabling it is a requirement for statelessness.\n\n## How it works\n\nAt a hard fork:\n\n- The `SELFDESTRUCT` opcode (`0xff`) is renamed **`SENDALL`**.\n- It now only moves all of the account's ETH to the target address, immediately.\n- It **no longer** deletes code or storage and does not change the nonce.\n- All gas refunds related to `SELFDESTRUCT` are removed.\n\nContracts that only used `SELFDESTRUCT` to sweep their ETH keep working. What breaks:\n\n- **Metamorphic / redeploy patterns**: destroying a contract and re-creating different code at the same address with `CREATE2`. After this change the old code never goes away, so redeployment fails. The spec says upgradeability should use delegate-call proxies instead.\n- **\"Destroy to lock\" patterns**, where a contract self-destructs at the end of an operation so nobody else can use it.\n- Using `SELFDESTRUCT` to burn non-ETH tokens held by the contract (the authors knew of no such use).\n\n## Sample code\n\nCode that only uses `selfdestruct` to sweep funds behaves the same under SENDALL, except the contract stays alive afterwards:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Piggy {\n    address public immutable owner = msg.sender;\n    receive() external payable {}\n\n    function smash() external {\n        require(msg.sender == owner, \"not owner\");\n        // Before: ETH sent to owner AND code/storage deleted.\n        // Under EIP-4758 (SENDALL): ETH sent to owner, contract keeps its code.\n        selfdestruct(payable(owner));\n    }\n}\n```\n\nA safer pattern that works under any rule set:\n\n```solidity\nfunction withdrawAll() external {\n    require(msg.sender == owner, \"not owner\");\n    (bool ok, ) = owner.call{value: address(this).balance}(\"\");\n    require(ok, \"send failed\");\n}\n```\n\n## Things to know\n\n- Status: **Stagnant**. Ethereum took a softer route: [EIP-6049](/eip-6049/) formally deprecated `SELFDESTRUCT`, and [EIP-6780](/eip-6780/) (Cancun) restricts it so code and storage are only deleted when the contract was created in the same transaction. Otherwise it just sends the ETH, which is close to SENDALL.\n- Like SENDALL, `SELFDESTRUCT` still sends ETH without calling the recipient, so a contract can receive ETH without its `receive` function running. Do not rely on `address(this).balance` for accounting.\n- Solidity compilers emit a deprecation warning for `selfdestruct`; avoid it in new code.\n"},"ja":{"lang":"ja","tldr":"SELFDESTRUCT を SENDALL に変える提案。コントラクトの ETH を送るだけでコードやストレージは削除せず、Ethereum を Verkle ツリーとステートレス化に備えさせる。","tags":["evm","selfdestruct","opcodes","statelessness","core"],"related":[6780,6049],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-4758/","markdown":"## 何を解決するのか\n\n`SELFDESTRUCT` はアカウントを消去します。コード、すべてのストレージ、そして nonce が対象です。これは大きく、上限のないステート変更です。Verkle ツリーでは 1 つのアカウントのデータが、アカウントのルートと明確には結びつかない多数のキーに分散されるため、「このアカウントに属するすべて」を削除することは現実的でなくなります。\n\n仕様は、`SELFDESTRUCT` を使い続ける強い理由はもう残っておらず、これを無効化することがステートレス化の要件だと主張しています。\n\n## 仕組み\n\nハードフォーク時に:\n\n- `SELFDESTRUCT` opcode（`0xff`）は **`SENDALL`** に名称変更されます。\n- アカウントの ETH をすべて、即座にターゲットアドレスへ移すだけになります。\n- コードやストレージは**削除されなくなり**、nonce も変更されません。\n- `SELFDESTRUCT` に関連するガスのリファンドはすべて削除されます。\n\nETH を回収するためだけに `SELFDESTRUCT` を使っていたコントラクトは、引き続き動作します。壊れるのは次のものです。\n\n- **メタモルフィック／再デプロイのパターン**: コントラクトを破棄し、`CREATE2` で同じアドレスに別のコードを作り直すもの。この変更後は古いコードが消えないため、再デプロイは失敗します。仕様は、アップグレード性には delegate-call プロキシを使うべきだとしています。\n- **「破棄してロックする」パターン**: 操作の最後にコントラクトが自己破棄し、他の誰も使えないようにするもの。\n- コントラクトが保有する ETH 以外のトークンをバーンするために `SELFDESTRUCT` を使うこと（作者たちはそのような用途を知りませんでした）。\n\n## サンプルコード\n\n資金を回収するためだけに `selfdestruct` を使うコードは、SENDALL でも同じ動きになります。ただし、その後もコントラクトは存続します。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Piggy {\n    address public immutable owner = msg.sender;\n    receive() external payable {}\n\n    function smash() external {\n        require(msg.sender == owner, \"not owner\");\n        // Before: ETH sent to owner AND code/storage deleted.\n        // Under EIP-4758 (SENDALL): ETH sent to owner, contract keeps its code.\n        selfdestruct(payable(owner));\n    }\n}\n```\n\nどのルールセットでも動く、より安全なパターン:\n\n```solidity\nfunction withdrawAll() external {\n    require(msg.sender == owner, \"not owner\");\n    (bool ok, ) = owner.call{value: address(this).balance}(\"\");\n    require(ok, \"send failed\");\n}\n```\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。Ethereum はより穏やかな道を選びました。[EIP-6049](/eip-6049/) が `SELFDESTRUCT` を正式に非推奨にし、[EIP-6780](/eip-6780/)（Cancun）が、コードとストレージの削除をコントラクトが同じトランザクション内で作成された場合のみに制限しました。それ以外では ETH を送るだけで、SENDALL に近い動作です。\n- SENDALL と同様に、`SELFDESTRUCT` は受取先を呼び出さずに ETH を送るため、コントラクトは `receive` 関数が実行されないまま ETH を受け取ることがあります。会計に `address(this).balance` を当てにしないでください。\n- Solidity コンパイラは `selfdestruct` に対して非推奨の警告を出します。新しいコードでは使わないでください。\n"},"ko":{"lang":"ko","tldr":"SELFDESTRUCT를 SENDALL로 바꾸자는 제안. 컨트랙트의 ETH만 대상에게 보내고 코드나 스토리지는 절대 삭제하지 않아, 이더리움이 Verkle 트리와 무상태(statelessness)를 준비하게 한다.","tags":["evm","selfdestruct","opcodes","statelessness","core"],"related":[6780,6049],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-4758/","markdown":"## 어떤 문제를 해결하나요?\n\n`SELFDESTRUCT`는 계정을 지웁니다. 코드, 모든 스토리지, nonce가 대상입니다. 이는 크고 상한이 없는 상태 변경입니다. Verkle 트리에서는 한 계정의 데이터가 계정 루트와 뚜렷하게 연결되지 않은 여러 키에 흩어져 있어서, \"이 계정에 속한 모든 것\"을 삭제하는 것이 비현실적이 됩니다.\n\n명세는 `SELFDESTRUCT`를 계속 쓸 강력한 이유가 더는 남아 있지 않으며, 이를 비활성화하는 것이 무상태를 위한 요건이라고 주장합니다.\n\n## 어떻게 동작하나요?\n\n하드포크 시점에:\n\n- `SELFDESTRUCT` opcode(`0xff`)의 이름이 **`SENDALL`**로 바뀝니다.\n- 이제 계정의 ETH 전부를 대상 주소로 즉시 옮기기만 합니다.\n- 코드나 스토리지를 **더 이상 삭제하지 않으며** nonce도 바꾸지 않습니다.\n- `SELFDESTRUCT`와 관련된 가스 환급은 모두 제거됩니다.\n\nETH를 쓸어 담는 용도로만 `SELFDESTRUCT`를 쓰던 컨트랙트는 계속 동작합니다. 깨지는 것은 다음과 같습니다.\n\n- **메타모픽 / 재배포 패턴**: 컨트랙트를 파괴하고 `CREATE2`로 같은 주소에 다른 코드를 다시 만드는 방식. 이 변경 이후 예전 코드가 사라지지 않으므로 재배포는 실패합니다. 명세는 업그레이드 가능성을 위해 delegatecall 프록시를 쓰라고 말합니다.\n- **\"파괴해서 잠그기\" 패턴**: 작업이 끝날 때 컨트랙트가 자폭해 다른 누구도 쓰지 못하게 하는 방식.\n- 컨트랙트가 보유한 ETH 이외의 토큰을 소각하려고 `SELFDESTRUCT`를 쓰는 것(저자들은 그런 사용 사례를 알지 못했습니다).\n\n## 샘플 코드\n\n자금을 쓸어 담는 용도로만 `selfdestruct`를 쓰는 코드는 SENDALL에서도 똑같이 동작합니다. 다만 그 뒤에도 컨트랙트가 살아 있습니다.\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Piggy {\n    address public immutable owner = msg.sender;\n    receive() external payable {}\n\n    function smash() external {\n        require(msg.sender == owner, \"not owner\");\n        // Before: ETH sent to owner AND code/storage deleted.\n        // Under EIP-4758 (SENDALL): ETH sent to owner, contract keeps its code.\n        selfdestruct(payable(owner));\n    }\n}\n```\n\n어떤 규칙 아래서도 동작하는 더 안전한 패턴:\n\n```solidity\nfunction withdrawAll() external {\n    require(msg.sender == owner, \"not owner\");\n    (bool ok, ) = owner.call{value: address(this).balance}(\"\");\n    require(ok, \"send failed\");\n}\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 이더리움은 더 완만한 길을 택했습니다. [EIP-6049](/eip-6049/)가 `SELFDESTRUCT`를 공식적으로 지원 중단(deprecated)했고, [EIP-6780](/eip-6780/)(Cancun)은 컨트랙트가 같은 트랜잭션에서 생성된 경우에만 코드와 스토리지를 삭제하도록 제한합니다. 그렇지 않으면 ETH만 보내는데, 이는 SENDALL에 가깝습니다.\n- SENDALL과 마찬가지로 `SELFDESTRUCT`는 수신자를 호출하지 않고 ETH를 보내므로, 컨트랙트는 `receive` 함수가 실행되지 않은 채 ETH를 받을 수 있습니다. 회계에 `address(this).balance`를 의존하지 마세요.\n- Solidity 컴파일러는 `selfdestruct`에 대해 지원 중단 경고를 냅니다. 새 코드에서는 피하세요.\n"},"zh":{"lang":"zh","tldr":"建议把 SELFDESTRUCT 改为 SENDALL：只把合约的 ETH 发送给目标地址，永不删除代码或存储，为以太坊迈向 Verkle 树和无状态做准备。","tags":["evm","selfdestruct","opcodes","statelessness","core"],"related":[6780,6049],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-4758/","markdown":"## 它解决什么问题？\n\n`SELFDESTRUCT` 会抹掉一个账户：它的代码、全部存储和 nonce。这是一个庞大且没有上限的状态变更。在 Verkle 树中，一个账户的数据分散在许多键上，这些键与账户根并没有明显的关联，因此删除\"属于该账户的一切\"变得不切实际。\n\n规范认为，已经没有使用 `SELFDESTRUCT` 的有力理由，并且禁用它是实现无状态的一项要求。\n\n## 它如何运作\n\n在一次硬分叉时：\n\n- `SELFDESTRUCT` 操作码（`0xff`）被重命名为 **`SENDALL`**。\n- 它现在只会立即把账户的全部 ETH 转给目标地址。\n- 它**不再**删除代码或存储，也不改变 nonce。\n- 所有与 `SELFDESTRUCT` 相关的 gas 退款都被移除。\n\n只用 `SELFDESTRUCT` 来清扫 ETH 的合约可以继续工作。会出问题的是：\n\n- **变形（metamorphic）/ 重新部署模式**：销毁一个合约，再用 `CREATE2` 在同一地址重建不同的代码。这项改动之后，旧代码永远不会消失，所以重新部署会失败。规范指出，可升级性应该改用 delegatecall 代理。\n- **\"销毁即锁定\"模式**：合约在操作结束时自毁，使其他人无法再使用它。\n- 用 `SELFDESTRUCT` 销毁合约持有的非 ETH 代币（作者不知道有这样的用法）。\n\n## 示例代码\n\n只用 `selfdestruct` 来清扫资金的代码，在 SENDALL 下行为相同，只是之后合约依然存在：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Piggy {\n    address public immutable owner = msg.sender;\n    receive() external payable {}\n\n    function smash() external {\n        require(msg.sender == owner, \"not owner\");\n        // Before: ETH sent to owner AND code/storage deleted.\n        // Under EIP-4758 (SENDALL): ETH sent to owner, contract keeps its code.\n        selfdestruct(payable(owner));\n    }\n}\n```\n\n在任何规则集下都能工作的更安全的写法：\n\n```solidity\nfunction withdrawAll() external {\n    require(msg.sender == owner, \"not owner\");\n    (bool ok, ) = owner.call{value: address(this).balance}(\"\");\n    require(ok, \"send failed\");\n}\n```\n\n## 需要注意\n\n- 状态：**Stagnant**。以太坊走了一条更温和的路线：[EIP-6049](/eip-6049/) 正式弃用了 `SELFDESTRUCT`，[EIP-6780](/eip-6780/)（Cancun）对其加以限制，只有当合约是在同一笔交易中创建时才会删除代码和存储。否则它只发送 ETH，这与 SENDALL 很接近。\n- 和 SENDALL 一样，`SELFDESTRUCT` 发送 ETH 时仍不会调用接收方，因此合约可以在其 `receive` 函数不运行的情况下收到 ETH。不要依赖 `address(this).balance` 做记账。\n- Solidity 编译器会对 `selfdestruct` 发出弃用警告，新代码中请避免使用。\n"}}}
