useBlockNumber
Invoke a callback on every block or with a polling time. On block is the prefered method.
Returns the block number.
How to import
import { useBlockNumber } from 'eth-hooks';
How to use
useBlockNumber(scaffoldAppProviders.mainnetAdaptor?.provider, (blockNumber) =>
console.log(`⛓ A new mainnet block is here: ${blockNumber}`)
);
or
useBlockNumber(scaffoldAppProviders.localAdaptor?.provider, (blockNumber) =>
console.log(`⛓ A new local block is here: ${blockNumber}`)
);