block-checker
v2.0.9
Published
A block tracker for the Network blockchain.
Downloads
40
Maintainers
Readme
Block tracker
Tracker for laster block number
How to use
const Checker = require("block-checker");
const web3 = require("web3");
const httpProvider = new web3.providers.HttpProvider(
"https://bsc-dataseed3.binance.org/"
);
const HttpsWeb3 = new web3(httpProvider);
const check = new Checker(HttpsWeb3, 1000);
check.start();
check.on("latest", (blockNumber) => console.log("latest", blockNumber));
check.on("sync", ([prev, current]) => console.log("sync", { prev, current }));
check.on("run", (timestamp) => console.log("Run", timestamp));
check.on("error", (error) => console.log("error", error));
Don't wanna get newest block?
const delayBlock = 10;
const check = new Checker(HttpsWeb3, 1000, delayBlock);