Web3.js integration

Web3.js is a JavaScript library built for interacting with the Ethereum blockchain and other EVM-compatible chains. It is used to send JSON-RPC calls to the Ethereum node via HTTP, IPC, or WebSocket connection to read data from the blockchain, make transactions, or deploy smart contracts.

Install Web3.js

Use your preferred package manager:

bashnpm install web3
bashyarn add web3
bashdist/web3.min.js

Set up your connection to GetBlock

javascript// Import the Web3 library (v4 exports Web3 as a named export)
const { Web3 } = require('web3');

// Set GetBlock as the provider (replace <region> and ACCESS_TOKEN with your actual values)
var web3 = new Web3('https://shared.<region>.getblock.io/ACCESS_TOKEN');

// Initialize web3 method
web3.eth.getBlockNumber().then(console.log);

For additional methods and options, refer to the official Web3.js documentation.