EIP-8058 · Draft · Core · 2025-10-22
EIP-8058: Contract Bytecode Deduplication Discount
Waives the per-byte code deposit gas when a deployment's bytecode is identical to code already used by an address in the transaction's access list, since clients store each unique bytecode only once.
What problem does it solve?
When a contract is deployed, the creator pays GAS_CODE_DEPOSIT for every byte of runtime code stored. Clients, however, store code by its hash: if ten accounts have identical bytecode, there is one copy on disk and ten accounts pointing at it. Deploying a duplicate costs nodes almost nothing extra, yet it is charged as if it were new.
This matters more if the deposit price rises. EIP-8037 proposes raising GAS_CODE_DEPOSIT from 200 to 1,900 gas per byte; the EIP-8058 authors note that would make the code deposit alone for a 24 KB contract roughly 46.6M gas. Factories and apps that deploy many identical contracts would pay heavily for storage they do not use.
The obvious fix, "check whether this code is already in the database", would break consensus: full-sync and snap-sync nodes hold different sets of code. EIP-8058 needs a check that gives the same answer on every node.
How it works
The check uses the transaction's existing EIP-2930 access list. No new fields or transaction types are added.
- Before execution, build a set
Wof code hashes: for every address in the access list that exists in state and has code, add itscodeHash. - When a contract creation (transaction,
CREATEorCREATE2) succeeds with bytecodeB, computeH = keccak256(B). - If
His inW, the bytecode is a duplicate: skip theGAS_CODE_DEPOSIT * len(B)charge and just point the new account atH. - Otherwise charge the deposit as usual and store the code.
Reading those code hashes is already paid for by the access-list and cold-access costs of EIP-2929, so the check itself costs no extra gas. Because W depends only on the transaction and current state, every node gets the same result.
A later transaction in the same block can reference a contract deployed earlier in that block. Two transactions that deploy the same new code without referencing each other both pay full price.
Sample code
Deploying a copy of an existing contract with the discount (ethers v6). The only change is listing an address that already has the same code:
const tx = await wallet.sendTransaction({
data: creationBytecode, // creation code; its returned runtime code is what gets compared
type: 2,
accessList: [
{ address: existingInstance, storageKeys: [] }, // already has identical runtime code
],
});
await tx.wait();
The rule in pseudocode:
W = {load_account(a).code_hash for a in tx.access_list
if account_exists(a) and has_code(a)}
H = keccak256(runtime_code)
if H not in W:
charge(GAS_CODE_DEPOSIT * len(runtime_code))
persist_code(H, runtime_code)
link_codehash(new_account, H)
Things to know
- Status: Draft. It requires a network upgrade, and the benefit depends mainly on whether a higher code deposit price such as EIP-8037 is adopted.
- Comparison is on the deployed runtime code, not the creation code. Constructor arguments or immutables that change the runtime bytes mean no match.
- The discount is opt-in: transactions without the right access-list entry pay exactly as today.
- Adding an address to the access list has its own cost, which is small next to the deposit for any non-trivial contract.
- Tooling such as
eth_estimateGasshould account for the discount when an access list is present. - Related proposals also reprice code: EIP-7907 meters loading of large contracts.