watchBlockNumber
Action for subscribing to block number changes.
import { watchBlockNumber } from '@wagmi/core'Usage
By default, the callback will be invoked when the Public Client changes.
import { watchBlockNumber } from '@wagmi/core'
const unwatch = watchBlockNumber(
{
chainId: 1,
},
(blockNumber) => console.log(blockNumber),
)Return Value
unwatch is a function that can be called to unsubscribe from the block number change event.
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 { watchBlockNumber } from '@wagmi/core'
const unwatch = watchBlockNumber(
{
chainId: 1,
},
(blockNumber) => console.log(blockNumber),
)listen
Listen to network for block number changes.
import { watchBlockNumber } from '@wagmi/core'
const unwatch = watchBlockNumber(
{
listen: true,
},
(blockNumber) => console.log(blockNumber),
)