Ethers.js integration
Set up GetBlock as a provider using Ethers.js library to interact with the blockchain and streamline your dApp development process.
Install Ethers.js
npm install ethersyarn add ethersSet GetBlock as a provider
// Import the Ethers library
const { ethers } = require('ethers');
// Set up the provider (replace ACCESS_TOKEN with your actual token)
const provider = new ethers.JsonRpcProvider('https://go.getblock.io/ACCESS_TOKEN');
//Call a method using the provider
const main = async () => {
const blockNumber = await provider.getBlockNumber();
console.log("Latest Block Number:", blockNumber);
};
// Call the main function
main();Last updated
Was this helpful?