watchBlockNumber

Watches the block number for a specific chain.

Example

import { watchBlockNumber } from "thirdweb";
const unwatch = watchBlockNumber({
client,
chainId,
onNewBlockNumber: (blockNumber) => {
// do something with the block number
},
onError: (err) => {
// do something if getting the block number fails
},
});
// later stop watching
unwatch();
function watchBlockNumber(opts: WatchBlockNumberOptions): () => void;

Parameters

The options for watching the block number.

Type

let opts: {
chain: Chain;
client: ThirdwebClient;
latestBlockNumber?: bigint;
onError?: (error: Error) => void;
onNewBlockNumber: (blockNumber: bigint) => void;
overPollRatio?: number;
};

Returns

let returnType: () => void;

The unwatch function.