Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
eth_chainId – 1auth
Skip to content

eth_chainId

Returns the chain ID of the currently selected network. This is useful for verifying which blockchain your dApp is connected to before initiating transactions, and for displaying network information to users.

Try it

Parameters

None.

Returns

string - The current chain ID as a hexadecimal string (e.g., "0x1" for Ethereum mainnet).

Example

const chainId = await provider.request({ method: 'eth_chainId' });
console.log(chainId); // "0x1" (mainnet), "0x89" (polygon), etc.

Notes

  • The chain ID is returned as a hex-encoded string, not a number
  • Use parseInt(chainId, 16) to convert to a number if needed
  • This method does not require the user to be connected