eth_getCode - HyperEVM

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

This method returns code at a given address.

Parameters

Parameter
Type
Required
Description

address

string

Yes

Address of the contract.

block

string

Yes

Block parameter (only "latest" supported).

Request

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

Response

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

Response Parameters

Field
Type
Description

result

string

Bytecode at the address (hex). Returns "0x" for EOAs.

Use Case

The eth_getCode method is essential for:

  • Verifying if an address is a contract

  • Contract verification systems

  • Security analysis tools

  • Distinguishing EOAs from contracts

  • Smart contract explorers

Error Handling

Error Code
Message
Cause

-32602

Invalid params

Invalid address format.

-32603

Internal error

Node issue.

Web3 Integration

Last updated

Was this helpful?