watchBlockNumber

Watch for a new block number on a given network.

Example

// this will log out the new block number every time a new block is finalized
const unsubscribe = watchBlockNumber({
network: "ethereum",
onBlockNumber: (blockNumber) => {
console.log("new block number", blockNumber);
},
});
// later on you can call unsubscribe to stop listening for new blocks
unsubscribe();
function watchBlockNumber(params: WatchBlockNumberParams): () => void;

Parameters

Type

Returns

let returnType: () => void;

An unsubscribe function that will stop listening for new blocks when called