Part III · Chapter 29 of 43 · Shanghai · Capella

EIP-3860: metering the code that makes code

A contract's runtime bytecode has been size-capped since 2016 — but the initcode that produces it was neither capped nor charged for the O(n) work every node does to process it. Supply megabytes of initcode and the whole network scans it almost for free. EIP-3860 caps initcode and charges per word.

Updated Jul 2, 2026 · 7 min
Assumed
  • contract creation (CREATE / CREATE2)
  • gas & metering the network's work

Shanghai, April 2023. Deploying a contract is a two-part act. You send a small program — the initcode — and the EVM runs it; whatever bytes it returns become the contract’s permanent runtime code. Since 2016, runtime code has been capped at 24576 bytes (EIP-170), and you pay to store it. But the initcode itself slipped through: it was never size-limited, and the O(n) work the network must do just to process it wasn’t fully charged. That’s a small crack — and in gas economics, an unpriced O(n) operation is exactly the shape of a denial-of-service. EIP-3860 seals it. Let’s derive it.

1 step The unpriced scan

The problem: initcode was uncapped and its O(n) work underpriced

When the EVM is handed initcode, it doesn’t just execute it — it must first do work proportional to the initcode’s length, regardless of what the code does. The clearest example is JUMPDEST analysis Before running bytecode, the EVM scans the entire program to mark which byte offsets are valid jump destinations (JUMPDEST opcodes). It's O(n) in the code length and must be done over the whole initcode — work every node repeats, whether or not the code ever runs to completion. : every node scans the whole initcode to find valid jump targets. Runtime code was capped and paid for, but initcode was uncapped, and this per-byte scanning wasn’t metered in proportion to its size. So an attacker could hand the network megabytes of initcode and make every node grind through it for a fee far below the real cost — an underpriced O(n) operation, the classic DoS shape.

creating a contract: run initcode → return runtime code initcode — uncapped, per-byte scan unpriced runtime ≤ 24576 every node runs JUMPDEST analysis over the whole initcode — O(n) attacker supplies megabytes of initcode all that scanning costs the network — but is barely charged an underpriced denial-of-service on contract creation
Contract creation runs initcode to return runtime code (capped at 24576 bytes since EIP-170). But initcode itself was uncapped, and the O(n) JUMPDEST scan every node runs over it was underpriced — so huge initcode forces network-wide work for almost nothing. An underpriced denial-of-service.

→ Step 2: charge for the size, and bound it.

2 step Meter and cap

EIP-3860: two gas per word, plus a hard cap

The fix is the same principle Ethereum applies whenever it finds unpriced O(n) work: make the cost track the size. EIP-3860 adds an initcode word charge An extra 2 gas per 32-byte word of initcode, levied on CREATE, CREATE2, and contract-creation transactions. It directly prices the length-proportional work (like JUMPDEST analysis) the network does on the initcode. of 2 gas per 32-byte word of initcode on CREATE, CREATE2, and creation transactions — so the longer the initcode, the more you pay, exactly matching the scan. And it adds a initcode size cap A hard limit of 49152 bytes (MAX_INITCODE_SIZE = 2 × MAX_CODE_SIZE) on initcode. Exceeding it is an immediate failure, bounding the worst-case work a single creation can impose. of 49152 bytes — exactly twice the runtime limit — so no single creation can be unboundedly large. Cost now scales with work, and work is bounded.

EIP-3860: price the initcode by its size initcode, split into 32-byte words 32B32B32B32B32B +2 gas per word — cost now tracks the scan hard cap: initcode ≤ 49152 B (2× runtime) no unbounded initcode, no unpriced O(n) work
EIP-3860 charges 2 gas per 32-byte word of initcode, so cost tracks the length-proportional scan, and caps initcode at 49152 bytes (2× the runtime limit). No unbounded initcode, no unpriced O(n) work — the standard 'meter the work' fix.

→ Step 3: creation and runtime finally match.

3 step Two matching limits

The payoff: symmetric, DoS-safe creation

With EIP-3860, the two halves of a contract’s life are finally symmetric: initcode is capped at 49152 bytes and metered per word; runtime code is capped at 24576 bytes (EIP-170) and paid on deposit. Contract creation is DoS-safe — no unbounded input, no unpriced O(n) work. The change is nearly invisible to ordinary deployments and slightly raises the cost of CREATE2 factory A contract that deploys other contracts via CREATE2, often at deterministic addresses. Because these patterns deploy many contracts, the new per-word initcode charge is the place EIP-3860's cost is most noticeable. patterns, which deploy contracts en masse. It’s a small EIP with a clear pedigree: the same lesson as EIP-150 — when the network does work proportional to your input, you must pay proportionally.

two matching limits, both metered initcode ≤ 49152 · +2/word runtime (EIP-170) ≤ 24576 creation is DoS-safe · CREATE2 factories pay the word charge the same 'meter the O(n) work' lesson as EIP-150
Initcode (≤ 49152 bytes, +2 gas/word) and runtime code (≤ 24576 bytes, EIP-170) are now a matching, metered pair. Creation is DoS-safe; CREATE2 factories pay the small word charge. The same 'meter the O(n) work' principle as EIP-150's I/O repricing.
04 Go Deeper Where to take it from here