Skip to content
On this page

getChainId

Returns the chain ID associated with the current network

Import

ts
import { getChainId } from 'viem/public'

Usage

ts
import { getChainId } from 'viem/public'
import { publicClient } from '.'
 
const block = await getChainId(publicClient) 
// 1

Returns

number

The current chain ID.

Released under the MIT License.