ERC-7744 · Last Call · ERC · 2024-07-16
ERC-7744: Code Index
A single onchain registry that maps a contract's bytecode hash to a deployed address, so code can be referenced, audited and allow-listed by what it is rather than where it lives.
What problem does it solve?
Contracts are usually referenced by address. But an address says little about the code behind it: proxies can swap implementations, and the same audited code may be deployed at many addresses. An auditor who reviewed some bytecode, or a protocol that wants to allow-list "this exact code", has no common place to point to.
ERC-7744 defines a global Code Index: a contract keyed by codehash. Anyone can register a deployed contract, and anyone can later look up a deployed instance of a given bytecode by its hash. Auditors can sign hashes, protocols can allow-list them before deployment, and dapps can reuse an existing deployment instead of redeploying.
How it works
The registry is tiny:
register(address container): readscontainer.codehashand storesindex[codehash] = container, emittingIndexed(container, codehash). It reverts if the address has no code, or if its code starts with the EIP-7702 delegation prefix0xef0100(delegated EOAs are not indexed).get(bytes32 id): returns the address registered for that hash, or zero.
Entries cannot be overwritten, which guards against hash-collision games. The one exception: if the previously indexed address no longer holds valid code (for example after self-destruct), a new address may be registered for the same hash.
The spec defines a canonical deployment: a fixed compiler configuration (solc 0.8.28) deployed with CREATE2 through the common deterministic deployer, producing a vanity address beginning 0xC0De1D. Check the exact address in the spec before relying on it.
Sample code
Look up and register code with ethers v6:
import { Contract, JsonRpcProvider, Wallet, keccak256 } from "ethers";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const signer = new Wallet(process.env.PRIVATE_KEY!, provider);
const codeIndex = new Contract(
process.env.CODE_INDEX!, // canonical address from the ERC-7744 spec
[
"function register(address container)",
"function get(bytes32 id) view returns (address)",
],
signer,
);
const hash = keccak256(await provider.getCode(target)); // same as EXTCODEHASH
const existing: string = await codeIndex.get(hash);
if (existing === "0x0000000000000000000000000000000000000000") {
await (await codeIndex.register(target)).wait();
}
In Solidity, a contract can verify that a dependency runs known code:
require(dep.codehash == AUDITED_HASH, "unexpected code");
Things to know
- Status: Last Call (deadline 2025-07-29 in the spec); not yet Final.
- Indexing says nothing about safety: malicious code can be registered too. Trust comes from whoever attests to a hash, not from the registry.
- Only bytecode is indexed, not storage. Two contracts with the same code can hold very different state.
- Constructor arguments baked into immutables change the runtime bytecode, so they change the hash.