githubEdit

eth_chainId - Base

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

The eth_chainId method returns the chain ID of the Base network. This value is essential for EIP-155 transaction signing to prevent replay attacks across different networks. Base mainnet uses chain ID 8453.

Parameters

  • None

Request

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

Response

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

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

string

Hexadecimal chain ID (0x2105 = 8453 for Base mainnet)

Chain ID Reference

Network
Chain ID (Decimal)
Chain ID (Hex)

Base Mainnet

8453

0x2105

Base Sepolia

84532

0x14A34

Use Cases

  • Network Verification: Confirm connection to the correct network before transactions

  • Transaction Signing: Include chain ID in EIP-155 signatures to prevent replay attacks

  • Multi-Chain Applications: Route transactions to appropriate networks

  • Wallet Integration: Verify network configuration matches expected chain

  • Smart Contract Deployment: Ensure deployment targets the intended network

Error Handling

Error Code
Message
Description

-32603

Internal error

Node internal failure

-32600

Invalid request

Malformed JSON-RPC request

Web3 Integration

Last updated

Was this helpful?