---
eip: 2677
label: EIP-2677
title: Limit size of `initcode`
status: Withdrawn
type: Standards Track
category: Core
created: 2020-05-18
official: https://eips.ethereum.org/EIPS/eip-2677
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2677.md
canonical: https://eips.huatuo.xyz/eip-2677/
lang: en
tldr: A withdrawn proposal to cap contract creation initcode at 49152 bytes (twice the deployed-code limit) to stop cheap jumpdest-analysis and hashing DoS; it was replaced by EIP-3860, which shipped in Shanghai.
tags: [evm, contract-creation, initcode, dos, withdrawn]
---

# EIP-2677: Limit size of `initcode`

> Enforce a maximum size limit (maxinitcodesize) of 49152 (0xc000) for initcode.

**TL;DR:** A withdrawn proposal to cap contract creation initcode at 49152 bytes (twice the deployed-code limit) to stop cheap jumpdest-analysis and hashing DoS; it was replaced by EIP-3860, which shipped in Shanghai.

## What problem does it solve?

When a contract is created, the client first runs its *initcode*: the constructor code that returns the final runtime bytecode. Before executing any code, a client performs *jumpdest analysis*, a scan over every byte to find valid `JUMPDEST` positions. For `CREATE2` it also hashes the initcode to compute the new address ([EIP-1014](/eip-1014/)).

Both jobs scale with code length, but while deployed code has been capped at 24576 bytes since [EIP-170](/eip-170/), initcode had no size limit. A transaction could expand memory once and then repeatedly start creations from that same large buffer, forcing clients to analyse and hash huge blobs over and over for little gas. The spec notes this kind of abuse was exploited in June 2017, prompting a geth patch release.

## How it works

- Define `max_initcode_size = 49152` (`0xc000`), exactly 2× the EIP-170 code limit.
- Apply it to every creation path: `CREATE`, `CREATE2`, and a transaction with an empty `to` field.
- If initcode is longer than the limit, contract creation fails with an out-of-gas error.

A nice side effect of the limit is that any code offset and code length fit in 16 bits, which simplifies some client and tooling designs.

The proposal required a network upgrade since it changes consensus rules. It flagged one possible breaking case: factory contracts that embed several levels of child contracts inside a single initcode might exceed the limit (the authors said they knew of none).

## Sample code

Pseudocode for the check, as it would sit at the start of contract creation:

```python
MAX_CODE_SIZE = 0x6000          # 24576, from EIP-170
MAX_INITCODE_SIZE = 2 * MAX_CODE_SIZE  # 49152 = 0xc000

def create_contract(initcode: bytes, gas: int):
    if len(initcode) > MAX_INITCODE_SIZE:
        raise OutOfGasError("initcode too large")
    analyse_jumpdests(initcode)
    return execute(initcode, gas)
```

Checking your own initcode size before deploying (ethers v6):

```ts
import { ContractFactory, getBytes } from "ethers";

const deployTx = await factory.getDeployTransaction(...args);
const size = getBytes(deployTx.data!).length;
if (size > 49152) console.warn(`initcode is ${size} bytes, above the 49152-byte limit`);
```

## Things to know

- **Status: Withdrawn**, replaced by [EIP-3860](/eip-3860/). EIP-3860 keeps the same 49152-byte limit but also charges a small gas cost per 32-byte word of initcode, and makes an oversized create transaction invalid rather than just failing.
- EIP-3860 is the rule actually in force on mainnet since the Shanghai upgrade, so the 49152-byte figure from this proposal is still the one that matters today.
- If a deployment hits the limit, split the contract, use libraries, or deploy via proxies rather than one giant constructor.


---

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