eth_chainId - Optimism

eth_chainId. Returns the unique identifier of the Optimism chain

eth_chainId - optimism [Value: 0CU]
Provides the current network or chain ID, essential for signing replay-protected transactions as defined in EIP-155
Use cases

Use cases

  • Verify chain ID before signing new transactions
  • Ensure transactions are compatible with the head block
  • Identify the chain for network-specific operations
Constraints

Constraints

  • Chain ID must correspond to current head block
  • Client must handle missing chain ID with errors
  • Prefer eth_chainId over net_version for reliability
Get started
Unlock Access to 50+ chains
Boost your app's speed and reliability with dRPC - get your access API key

Language

Request
Examples
curl --request POST \
    --url https://optimism.drpc.org \
    --header 'accept: application/json' \
    --header 'content-type: application/json' \
    --data '
{
 "id": 1,
 "jsonrpc": "2.0",
 "method": "eth_chainId"
}
'
Copy
Response
200
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x1"
}
Copy

Request params

idinteger
jsonrpcstring
methodstring
ParametersThis method does not accept any parameters.

Response

200
Returns the current chain ID as an integer.

Response params

object
idinteger
jsonrpcstring
resultstring
Hexadecimal string that represents the current chain or network ID.