githubEdit

eth_getCode - Celo

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 the bytecode stored at a given address on the Celo network. This is useful for verifying contract deployments and distinguishing between EOAs (Externally Owned Accounts) and contract accounts.

Parameters

Parameter
Type
Required
Description

address

string

Yes

Contract address to query

blockNumber

string

Yes

Block number in hex, or "latest", "earliest", "pending"

Request Example

curl
curl -X POST https://go.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "eth_getCode",
  "params": [
    "0x765DE816845861e75A25fCA122bb6898B8B1282a",
    "latest"
  ]
}'

Response Example

Response Definition

Field
Type
Description

result

string

Contract bytecode as hex string

Use Cases

  • Verify contract deployment

  • Check if address is a contract or EOA

  • Analyze contract bytecode

  • Validate proxy implementations

Error Handling

Error Code
Description

-32602

Invalid params - malformed address

-32603

Internal error - node processing issues

SDK Integration

Last updated

Was this helpful?