> ## 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.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.chainstack.com/feedback

```json
{
  "path": "/reference/fantom-getchainid",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# eth_chainId | Fantom

Fantom API method that returns the current chain ID. Chain ID is used to sign replay-protected transactions and verify whether a network is the desired one. It was introduced in [EIP-155](https://eips.ethereum.org/EIPS/eip-155).

<Check>
  **Get your own node endpoint today**

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## Parameters

* `none`

## Response

* `quantity` — EIP-155 Chain ID

<Note>
  Use the [Chainstack EVM Knife](https://web3tools.chainstacklabs.com/hexadecimal-decimal) to convert the Chain ID from Hexadecimal to Decimal.
</Note>

## `eth_chainId` code examples

<CodeGroup>
  ```javascript web3.js theme={"system"}
  const { Web3 } = require("web3");
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const web3 = new Web3(NODE_URL);

  async function getChainId() {
    const chain = await web3.eth.getChainId();
    console.log(chain);
  }

  getChainId();
  ```

  ```javascript ethers.js theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const chainId = async () => {

      // This will return the value in Hex
      const chainId = await provider.send("eth_chainId");
      console.log(`Hex Chain ID: ${chainId}`);
    };

  chainId();
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3  
  node_url = "CHAINSTACK_NODE_URL"

  web3 = Web3(Web3.HTTPProvider(node_url)) 
  print(web3.eth.chain_id)  
  ```
</CodeGroup>

## Use case

One possible use case for the `eth_chainId` method is to determine which chain a user is connected to when using a DApp with the MetaMask browser extension. This can be useful to provide a customized user experience based on the specific chain that the user is interacting with.


## OpenAPI

````yaml /openapi/fantom_node_api/eth_chainId.json POST /4ab982aa70a7baead515ffdb5915df3f
openapi: 3.0.0
info:
  title: Fantom Node API
  version: 1.0.0
  description: This is an API for interacting with a Fantom node.
servers:
  - url: https://fantom-mainnet.core.chainstack.com
security: []
paths:
  /4ab982aa70a7baead515ffdb5915df3f:
    post:
      tags:
        - Update
      summary: eth_chainId
      operationId: getChainId
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: eth_chainId
                params:
                  type: array
                  default: []
      responses:
        '200':
          description: The network Chain ID
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string

````