---
eip: 6780
label: EIP-6780
title: SELFDESTRUCT only in same transaction
status: Final
type: Standards Track
category: Core
created: 2023-03-25
requires: 2681, 2929, 3529
official: https://eips.ethereum.org/EIPS/eip-6780
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6780.md
canonical: https://eips.huatuo.xyz/eip-6780/
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]
---

# EIP-6780: SELFDESTRUCT only in same transaction

> SELFDESTRUCT will recover all funds to the target but not delete the account, except when called in the same transaction as creation

**TL;DR:** 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.

## What problem does it solve?

`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.

The 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.

## How it works

The behaviour now depends on whether the contract was created **in the current transaction**.

**Contract created in an earlier transaction (the normal case):**

- The current execution frame halts.
- The entire balance is transferred to the target.
- Code, storage, nonce and the account itself are **not** deleted.
- If the target is the contract itself, nothing changes; ETH is no longer burned.

**Contract created earlier in the same transaction:**

- The old behaviour applies: balance sent to the target, the account and all its data deleted.
- If the target is the contract itself, that ETH is burned, as before.

"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/)).

## Sample code

Pseudocode for the new opcode logic:

```python
def selfdestruct(account, target):
    balance = state.get_balance(account)
    state.add_balance(target, balance)
    state.sub_balance(account, balance)        # net zero if target == account

    if account in tx.created_accounts:         # created in this same transaction
        state.set_balance(account, 0)          # burns ETH if target == account
        tx.accounts_to_delete.add(account)     # old behaviour: wipe code + storage
    halt_frame()
```

A pattern that **no longer works** – metamorphic upgrades via `CREATE2`:

```solidity
// Before Cancun: selfdestruct, then CREATE2 new code at the same address.
// After EIP-6780: selfdestruct leaves the code in place, so the second
// CREATE2 to that address fails because the account already has code.
function kill() external {
    require(msg.sender == owner);
    selfdestruct(payable(owner)); // now only moves the ETH out
}
```

## Things to know

- **Status: Final.** Activated on mainnet in the Cancun/Deneb ("Dencun") upgrade, together with [EIP-5656](/eip-5656/) `MCOPY`.
- Upgrade schemes based on `SELFDESTRUCT` + `CREATE2` redeployment are broken. Use proxy patterns such as [ERC-2535](/eip-2535/) or standard upgradeable proxies.
- Contracts that relied on self-targeted `SELFDESTRUCT` to burn ETH no longer burn it unless created in the same transaction.
- `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.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-6780
