Skip to main content
Defined in the Ethereum JSON-RPC Specification
Returns the bytecode at a given address. This is useful for verifying if an address is a contract or an externally owned account.

Parameters

string
required
The address to get bytecode from (20 bytes).
string
required
Integer block number, or the string “latest”, “earliest” or “pending”.

Returns

string
The bytecode at the given address as a hexadecimal string. Returns “0x” for externally owned accounts.

Error Handling

If the result is “0x”, the address is an externally owned account (EOA). If it contains bytecode, it’s a smart contract.