Skip to content
Alchemy Logo

eth_getCodeByHash

POST
/{apiKey}
CUs20

Returns the contract bytecode associated with a given code hash (the keccak256 hash of the bytecode). Unlike eth_getCode, which looks up code via an account address at a specific block, this method resolves code directly from its hash, letting callers deduplicate bytecode fetches when multiple accounts share the same implementation (e.g., minimal proxies, upgradeable proxies, EIP-7702 delegators). Used by MegaETH's stateless validator to fetch witness-referenced contract code on demand.

Path Parameters

stringrequireddefaults to docs-demo

For higher throughput, create your own API key

Request

stringformat: "^0x[0-9a-f]{64}$"required

The 32-byte keccak256 hash of the contract bytecode (codeHash field from an account).

Responses

200

The bytecode associated with the given code hash, as a hexadecimal string. Returns "0x" if no code is stored under this hash.

Was this page helpful?