---
eip: 8058
label: EIP-8058
title: Contract Bytecode Deduplication Discount
status: Draft
type: Standards Track
category: Core
created: 2025-10-22
requires: 2930
official: https://eips.ethereum.org/EIPS/eip-8058
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8058.md
canonical: https://eips.huatuo.xyz/eip-8058/
lang: en
tldr: "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."
tags: [gas, deployment, access-list, bytecode, core]
---

# EIP-8058: Contract Bytecode Deduplication Discount

> Reduces gas costs for deploying duplicate contract bytecode via access-list based mechanism

**TL;DR:** 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](/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](/eip-2930/) access list. No new fields or transaction types are added.

1. Before execution, build a set `W` of code hashes: for every address in the access list that exists in state and has code, add its `codeHash`.
2. When a contract creation (transaction, `CREATE` or `CREATE2`) succeeds with bytecode `B`, compute `H = keccak256(B)`.
3. If `H` is in `W`, the bytecode is a duplicate: skip the `GAS_CODE_DEPOSIT * len(B)` charge and just point the new account at `H`.
4. 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](/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:

```ts
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:

```python
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](/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_estimateGas` should account for the discount when an access list is present.
- Related proposals also reprice code: [EIP-7907](/eip-7907/) meters loading of large contracts.


---

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