NodeJs — Blockchain Basics with Node.js
Blockchain technology can be used to create decentralized apps (dApps). Using Node.js, you can build blockchain networks or interact with popular blockchains like Ethereum through Web3.js.
npm install web3
const Web3 = require('web3');
const web3 = new Web3('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID');
async function getBlockNumber() {
const blockNumber = await web3.eth.getBlockNumber();
console.log('Latest Ethereum Block:', blockNumber);
}
getBlockNumber();