EIPs Explained

EIP-6 · Final · Interface · 2015-11-22

EIP-6: Renaming SUICIDE opcode

Renamed the EVM's SUICIDE opcode to SELFDESTRUCT in Ethereum's programming languages, a purely cosmetic change made out of respect for people affected by suicide and depression.

What problem does it solve?

The EVM has an instruction (opcode 0xff) that deletes a contract and sends its remaining ether to a chosen address. In Ethereum's early days it was called SUICIDE, and Solidity and Serpent exposed it under that name.

EIP-6 argues that the word is needlessly painful for developers who live with depression or have lost someone to suicide. A security audit by Least Authority had also recommended a less loaded name such as "self-destruct". Since Ethereum was young, renaming early was cheap.

How it works

The change is at the language and tooling level, not in consensus:

  • The opcode byte stays 0xff, with the same gas cost and behavior. Nothing on-chain changes.
  • SELFDESTRUCT was added to Solidity and Serpent as an alias of SUICIDE, rather than replacing it outright, so existing source code kept compiling.
  • Documentation, disassemblers and clients gradually adopted the new name.

Because only the human-readable name changed, no hard fork was needed. This is why the EIP is in the "Interface" category rather than "Core".

Sample code

Modern Solidity only knows selfdestruct. The old suicide alias was removed from the language long ago.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Closable {
    address payable public owner = payable(msg.sender);

    function close() external {
        require(msg.sender == owner, "not owner");
        // Opcode 0xff, once called SUICIDE.
        // Since EIP-6780 this only sends the ether unless the contract
        // was created in the same transaction.
        selfdestruct(owner);
    }
}

In a disassembly you will now see:

PUSH20 0x...owner
SELFDESTRUCT   // 0xff

Things to know

  • This proposal is Final, and it is one of the earliest EIPs. It changed names only: bytecode written before and after is identical.
  • The opcode itself was later weakened. EIP-6049 formally deprecated SELFDESTRUCT, and EIP-6780 limited it so that it no longer deletes code or storage, except when called in the same transaction that created the contract. EIP-4758 proposed to deactivate it fully, but it is Stagnant.
  • Do not design new contracts around selfdestruct to "reset" or upgrade a contract. Use an upgradeable proxy or a migration pattern instead.

#evm #opcode #naming #selfdestruct

Details

Authors
Hudson Jameson <[email protected]>
Status
Final
Type
Standards Track / Interface
Created
2015-11-22
Required by

Machine-readable: Markdown · JSON