> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# eth_chainId | Optimism

> Optimism API method eth_chainId retrieves the current chain ID, which is a unique identifier for the blockchain network the node is connected to.

Optimism API method `eth_chainId` retrieves the current chain ID, which is a unique identifier for the blockchain network the node is connected to. The chain ID is crucial for transaction signing to prevent replay attacks across different chains.

## Parameters

* `none` — This method does not require any parameters.

## Response

* `result` — the current chain ID, encoded as a hexadecimal string. For example, the chain ID for Optimism Mainnet is `0xa`.

## Use case

The `eth_chainId` method is essential for:

* Wallets and applications that sign transactions, as the chain ID is used as part of the signing process to ensure transactions are only valid on the intended chain.
* Applications that interact with multiple blockchain networks and need to confirm the network they are communicating with.


## OpenAPI

````yaml openapi/optimism_node_api/eth_chainId.json POST /efb0a5eccd2caa5135eb54eba6f7f300
openapi: 3.0.0
info:
  title: eth_chainId example
  version: 1.0.0
  description: >-
    This is an API example for eth_chainId, a method to retrieve the current
    chain ID.
servers:
  - url: https://optimism-mainnet.core.chainstack.com
security: []
paths:
  /efb0a5eccd2caa5135eb54eba6f7f300:
    post:
      tags:
        - Ethereum Operations
      summary: eth_chainId
      operationId: chainId
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: eth_chainId
                id:
                  type: integer
                  default: 1
      responses:
        '200':
          description: The current chain ID
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string

````