The simplest method/function to retrieve the latest block number on ETH aka Ethereum Blockchain is via the following method:
1 2 3 4 5 6 7 | const Web3 = require('web3'); const getBlockNumber = async() => { const MAIN_ENDPOINT = "https://mainnet.infura.io/v3/..."; const web3 = new Web3(ENDPOINT); return await web3.eth.getBlockNumber(); } |
const Web3 = require('web3'); const getBlockNumber = async() => { const MAIN_ENDPOINT = "https://mainnet.infura.io/v3/..."; const web3 = new Web3(ENDPOINT); return await web3.eth.getBlockNumber(); }
You would need the web3 library:
1 | npm install web3 |
npm install web3
Ethereum Blockchain
- How to Fix "Returned Error: replacement transaction underpriced" when Sending the ETH on Ethereum Blockchain?
- How to Transfer or Send ETH to Another Wallet on Ethereum Blockchain?
- How to Check the Balance of a Ethereum Wallet Address?
- How to Check if a Given String is a Valid Ethereum Wallet Address?
- How to Get the Gas Price and Gas Fee on Ethereum Blockchain?
- How to Get the Latest Block Number (Head Block) on Ethereum Blockchain?
- Today.. Gas Fee was High
- Gas Fee is Fixed Regardless the Amount of ETH to Send
- The Simple Way to Watch the Transactions of an ETH Account
- Watch Gas Price Before You Send Steem to Swap ETH
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
115 wordsloading...
Last Post: How to Get the Gas Price and Gas Fee on Ethereum Blockchain?
Next Post: How to Check if a Given String is a Valid Ethereum Wallet Address?