• Core
  • Actions
  • fetchBlockNumber

fetchBlockNumber

Action for fetching the current block number.

This is a wrapper around viem's getBlockNumber.

import { fetchBlockNumber } from '@wagmi/core'

Usage

import { fetchBlockNumber } from '@wagmi/core'
 
const blockNumber = await fetchBlockNumber()

Return Value

bigint

Configuration

chainId (optional)

Force a specific chain id for the request. The wagmi Client's publicClient must be set up as a chain-aware function for this to work correctly.

import { fetchBlockNumber } from '@wagmi/core'
 
const blockNumber = fetchBlockNumber({
  chainId: 1,
})