eth_getCode

The eth_getCode method returns the compiled bytecode of a smart contract at a given address. This method retrieves the actual code deployed at an address, allowing you to verify if an address is a contract or an externally owned account (EOA), analyze contract implementations, and verify deployed contract code matches expected bytecode.

Developers use this method to distinguish between contract addresses and EOAs (which return "0x"), verify contract deployments, analyze proxy contract implementations, check if a contract has been self-destructed, and perform contract verification. The bytecode returned is the runtime bytecode (not the creation bytecode), which is what's actually executed when the contract is called. This method supports querying historical contract code by specifying different block parameters.


Parameters

parameter
type
description
address
string (required)
The address to query (20-byte hex string with 0x prefix)
blockParameter
string (required)
Block number in hex format (e.g., '0x10d4f') or one of the string tags: 'latest', 'earliest', or 'pending'
Return Object
field
type
description
result
string
The contract bytecode as a hexadecimal string. Returns "0x" (empty) if the address is an externally owned account (EOA) or if no code exists at the address. For contract addresses, returns the complete runtime bytecode that is executed when the contract is called. The bytecode consists of EVM opcodes and can be quite large for complex contracts.
Request Example
Request
Response Example
Response

Share on
Share on FacebookShare on XShare on LinkedIn
Did you find this page useful?