eth_getCode
Returns the compiled bytecode at a given address. Returns "0x" for externally owned accounts (EOAs).
Parameters
Section titled “Parameters”| Position | Name | Type | Description |
|---|---|---|---|
| 1 | address | string | The 20-byte address to query. Required. |
| 2 | block | string | Block number in hex, or "latest", "pending", "safe", "finalized", "earliest". Required. |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
result | string | The bytecode at the address as a hex string. "0x" if there is no code. |
Example
Section titled “Example”Request
Section titled “Request”curl https://mainnet.base.org \ -X POST \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "eth_getCode", "params": ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "latest"], "id": 1 }'curl https://mainnet-preconf.base.org \ -X POST \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "eth_getCode", "params": ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "pending"], "id": 1 }'Response
Section titled “Response”{ "jsonrpc": "2.0", "id": 1, "result": "0x608060405234801561001057600080fd5b50..."}