eth_getCode
The eth_getCode method returns the compiled bytecode of a smart contract at a given address on the Optimism network. 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. Returns empty (0x) for EOAs.
Parameters
parameter | type | description |
|---|---|---|
address | string (required) | The contract address (20 bytes) |
blockParameter | string (required) | Block number in hex or tag (latest, earliest, pending) |
Return Object
The method returns the contract bytecode as a hex string, or "0x" if address has no code.
Request Example
Request
Response Example
Response