Custom hook to fetch the block number of a specific network.
Creates a dedicated public client specifically for the provided chain, regardless of whether it's supported in the app configuration. Uses TanStack Query's suspense mode for data fetching.
The parameters object
The viem chain object for the target network
Optional
Optional TanStack Query options
The current block number as a bigint
const blockNumber = useNetworkBlockNumber({ chain: optimism, options: { refetchInterval: 5000 }}); Copy
const blockNumber = useNetworkBlockNumber({ chain: optimism, options: { refetchInterval: 5000 }});
Custom hook to fetch the block number of a specific network.
Creates a dedicated public client specifically for the provided chain, regardless of whether it's supported in the app configuration. Uses TanStack Query's suspense mode for data fetching.