eth_getCode - Monad

Example code for the eth_getCode JSON-RPC method. Complete guide on how to use eth_getCode JSON-RPC in GetBlock Web3 documentation.

This method returns code at a given address. Used to verify if an address is a smart contract.

Parameters

Parameter
Type
Required
Description

address

string

Yes

The address to get the code from.

blockNumber

string

No

Block number in hex, or "latest", "earliest", "pending", "safe", "finalized".

Request examples

cURL
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getCode",
    "params": ["0x55962b6c47ae83427d02bcb9832adef4ece7bbf6", "latest"],
    "id": "getblock.io"
}'

Response

response.json
{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x606060405260043610610062576000357c0100..."
}

Response Parameters

Field
Type
Description

result

string

The bytecode at the address. Returns "0x" for EOAs (externally owned accounts).

Use Case

The eth_getCode method is essential for:

  • Verifying if an address is a contract

  • Security checks before interactions

  • Contract bytecode analysis

  • Detecting proxy contracts

  • Block explorer functionality

  • Smart contract verification

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS-TOKEN.

-32602

Invalid params

Invalid address format.

-32000

Resource not found

Block not found.

Web3 Integration

Last updated

Was this helpful?