---
eip: 684
label: EIP-684
title: Revert creation in case of collision
status: Final
type: Standards Track
category: Core
created: 2023-03-20
official: https://eips.ethereum.org/EIPS/eip-684
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-684.md
canonical: https://eips.huatuo.xyz/eip-684/
lang: en
tldr: "Makes contract creation fail if the target address already has code or a nonzero nonce, so deployed code can never be silently replaced by a second \"creation\" at the same address."
tags: [evm, create2, security, core]
---

# EIP-684: Revert creation in case of collision

> Revert contract creation if address already has code

**TL;DR:** Makes contract creation fail if the target address already has code or a nonzero nonce, so deployed code can never be silently replaced by a second "creation" at the same address.

## What problem does it solve?

A basic promise of smart contracts is that the code at an address does not change. Contract addresses come from a hash: the sender and nonce for `CREATE`, or the deployer, salt and init code hash for [`CREATE2`](/eip-1014/). If two different creations could land on the same address and the second one overwrote the first, an attacker with enough computing power could find such a collision. They could then deploy harmless-looking code, win users' trust and funds, and later swap in malicious code.

EIP-684 closes that door: an address that is already "in use" cannot be created again.

## How it works

For **every** kind of contract creation (a creation transaction, `CREATE`, `CREATE2`, or anything else):

- if the destination address has a **nonzero nonce**, or
- if the destination address has **nonzero code length**,

the creation fails exactly **as if the first byte of the init code were an invalid opcode**. All gas given to the creation is used up, the caller gets `0` (the zero address) on the stack, and no state changes.

The rule applies **retroactively from genesis**. It is not a new behaviour: it began as GitHub issue #684, and [EIP-1014](/eip-1014/) (2018) already quotes it as the rule for collisions. The EIP document itself was written up in 2023 to record it formally.

An account that only has a balance (nonce 0, no code) is not a collision. ETH sent to a future `CREATE2` address in advance does not block deployment.

## Sample code

Deploying twice with the same `CREATE2` salt. The second attempt hits the EIP-684 rule:

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

contract Child {}

contract Factory {
    function deploy(bytes32 salt) external returns (address) {
        return address(new Child{salt: salt}());
    }
}

// factory.deploy(0x01)  -> succeeds, returns 0xAbC...
// factory.deploy(0x01)  -> reverts: address already has code and nonce 1
```

The same check written as client pseudocode:

```python
def can_create_at(state, addr) -> bool:
    acct = state.get(addr)
    return acct.nonce == 0 and len(acct.code) == 0
```

## Things to know

- Because a newly created contract's nonce starts at 1 ([EIP-161](/eip-161/)), a second creation at the same address in the same transaction always fails, even before any code is stored.
- `SELFDESTRUCT` used to clear the account, which allowed "metamorphic" contracts: destroy, then `CREATE2` again with the same salt and different code. [EIP-6780](/eip-6780/) removed this, except when both happen in the same transaction.
- [EIP-7610](/eip-7610/) (in Last Call) extends the rule to addresses that have **non-empty storage**.
- The opposite case, where a transaction is sent *from* an address that has code, is handled by [EIP-3607](/eip-3607/).


---

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