---
eip: 6049
label: EIP-6049
title: Deprecate SELFDESTRUCT
status: Final
type: Meta
created: 2022-11-27
official: https://eips.ethereum.org/EIPS/eip-6049
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6049.md
canonical: https://eips.huatuo.xyz/ko/eip-6049/
lang: ko
tldr: SELFDESTRUCT opcode를 공식적으로 폐기(deprecated)하고 그 동작이 바뀔 것이라고 개발자에게 경고한 Meta EIP. 이후 EIP-6780이 Cancun 업그레이드에서 실제로 변경했다.
tags: [selfdestruct, opcode, deprecation, meta, evm]
---

# EIP-6049: Deprecate SELFDESTRUCT

> Deprecate SELFDESTRUCT by discouraging its use and warning about a potential future behavior change.

**TL;DR:** SELFDESTRUCT opcode를 공식적으로 폐기(deprecated)하고 그 동작이 바뀔 것이라고 개발자에게 경고한 Meta EIP. 이후 EIP-6780이 Cancun 업그레이드에서 실제로 변경했다.

## 어떤 문제를 해결하나요?

`SELFDESTRUCT`는 컨트랙트의 코드와 스토리지를 삭제하고 그 ETH를 수혜자에게 보냅니다. 코어 개발자들은 오래전부터 이를 바꾸거나 제거하고 싶어 했습니다. 클라이언트 설계와 스테이트리스 이더리움 계획을 복잡하게 하고, (`CREATE2`를 통해) 컨트랙트를 파괴한 뒤 같은 주소에 다른 코드로 다시 배포할 수 있게 하기 때문입니다. 하지만 많은 컨트랙트가 이에 의존했고, 경고 없이 해가 지날수록 결국의 변경은 더 큰 혼란을 일으키게 됩니다.

EIP-6049는 프로토콜에서 아무것도 바꾸지 않습니다. 공식 공지입니다. **`SELFDESTRUCT`를 쓰지 마세요. 호환성을 깨는 변경이 옵니다.** 개발자들은 실제 변경이 적용되기 전에 분명한 신호를 받았습니다.

## 어떻게 동작하나요?

- 이 opcode의 문서(Yellow Paper의 비규범적 텍스트 포함)를 갱신해 폐기되었음을 표시하고 향후 호환성을 깨는 변경을 경고합니다.
- 클라이언트 변경은 없습니다. 이 EIP가 수락되었을 때 opcode는 이전과 똑같이 계속 동작했습니다.
- 컴파일러 도구도 뒤따랐습니다. Solidity는 0.8.18부터 `selfdestruct`에 대해 폐기 경고를 냅니다.

그 후에 일어난 일: Cancun 업그레이드(2024년 3월)에서 활성화된 [EIP-6780](/eip-6780/)이 `SELFDESTRUCT`를 제한했습니다. 이제는 컨트랙트가 생성된 **같은 트랜잭션**에서 호출될 때만 계정을 삭제합니다. 그렇지 않으면 컨트랙트의 ETH를 수혜자에게 보낼 뿐 코드와 스토리지는 그대로 둡니다.

## 샘플 코드

`SELFDESTRUCT`에 의존하던 패턴과 대신 해야 할 일:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract Legacy {
    address immutable owner = msg.sender;

    // DEPRECATED: after EIP-6780 this no longer deletes code or storage
    // (unless called in the creating transaction). It only moves the ETH.
    function kill() external {
        require(msg.sender == owner);
        selfdestruct(payable(owner)); // compiler warning since 0.8.18
    }
}

contract Modern {
    address immutable owner = msg.sender;
    bool public disabled;

    // Prefer an explicit "off switch" plus a normal withdrawal.
    function disable() external {
        require(msg.sender == owner);
        disabled = true;
        (bool ok, ) = owner.call{value: address(this).balance}("");
        require(ok);
    }

    modifier whenEnabled() { require(!disabled, "disabled"); _; }
}
```

## 알아둘 점

- 상태: **Final**. 유형: Meta. 문서와 프로세스의 변경일 뿐입니다.
- "selfdestruct 후 `CREATE2`로 재배포"(메타모픽 컨트랙트)를 전제로 업그레이드 방식을 설계하지 마세요. Cancun 이후 생성 트랜잭션 밖에서는 더 이상 동작하지 않습니다.
- `SELFDESTRUCT`로 ETH를 보내면 여전히 수신자의 `receive`/`fallback`을 우회합니다. 컨트랙트는 자신의 잔액이 자기 함수를 통해서만 바뀐다고 절대 가정해서는 안 됩니다.
- 이 opcode를 무력화하려던 이전 제안으로는 [EIP-4758](/eip-4758/)(Stagnant)이 있습니다. [EIP-3529](/eip-3529/)는 London 업그레이드에서 이미 `SELFDESTRUCT`의 가스 환급을 제거했습니다.


---

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