---
eip: 7784
label: EIP-7784
title: GETCONTRACT opcode
status: Review
type: Standards Track
category: Core
created: 2024-10-07
official: https://eips.ethereum.org/EIPS/eip-7784
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7784.md
canonical: https://eips.huatuo.xyz/eip-7784/
lang: en
tldr: "Proposes a GETCONTRACT opcode that looks up a deployed contract's address from the hash of its bytecode, so code can be referenced by content instead of by address."
tags: [evm, opcode, bytecode, core, registry]
---

# EIP-7784: GETCONTRACT opcode

> Global byte code accessing by its hash

**TL;DR:** Proposes a GETCONTRACT opcode that looks up a deployed contract's address from the hash of its bytecode, so code can be referenced by content instead of by address.

## What problem does it solve?

Contracts find each other by address. An address says nothing about what code is behind it, and with proxies the code can change while the address stays the same. If you want to depend on "this exact audited code", you have to trust whoever controls the address.

Content addressing, looking things up by the hash of their content, is a common fix in databases and storage systems. EIP-7784 proposes the same for the EVM: given a bytecode hash, return an address where that exact code lives. The spec's motivations include auditors attesting to bytecode hashes instead of deployments, allow-listing code before it is deployed, reusing existing deployments instead of redeploying identical code, and letting standards such as [EIP-7702](/eip-7702/) delegation refer to immutable code by hash.

## How it works

- **Opcode:** `GETCONTRACT`, value `0x4f`.
- **Stack:** pops one 32-byte `codehash`, pushes one item: the address holding that bytecode, or `0` if none is indexed.
- **Gas:** 150.
- **Errors:** if the code hash is invalid or retrieval fails, the instruction reverts.

To make lookups possible, every contract stored in the EVM must be added to the state trie under the key `keccak256(bytecode)`, but only if:

- the hash is not already indexed (the first deployment wins and is never re-indexed, which also blunts hash-collision tricks);
- the contract has not executed `SELFDESTRUCT`;
- its code hash is not `keccak256(0xef01)`, i.e. it is not an EIP-7702 delegation designator, since that code is temporary.

The hash used is the same value [EIP-1052](/eip-1052/) `EXTCODEHASH` returns for an account, so you can get the key from any existing deployment.

## Sample code

Hypothetical usage, mirroring the spec's example. No compiler supports `GETCONTRACT` today, so treat the assembly line as pseudocode:

```solidity
// Illustrative only: no Solidity version supports GETCONTRACT today.
function implementationFor(bytes32 codehash) public view returns (address impl) {
    assembly {
        // GETCONTRACT (0x4f): codehash -> address or 0
        impl := getcontract(codehash)
    }
    require(impl != address(0), "code not indexed");
}

// Getting the key from a known deployment works today:
function hashOf(address a) public view returns (bytes32) {
    return a.codehash; // EXTCODEHASH
}
```

## Things to know

- Status is **Review** and the opcode is not scheduled for any network upgrade.
- The index only says the bytecode matches. It says nothing about the contract's storage, which can differ between deployments and change over time, and nothing about whether the code is safe.
- The same source compiled with different settings, or deployed with different immutable values, yields different runtime bytecode and therefore a different hash.
- Indexing every contract adds entries to the state trie, and the proposed 150 gas price would need validation by client teams.


---

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