Before we begin, let register an account, they provides endpoints to access to ETH Node for testing.


yarn add web3

To create a network instance: You can listen on transactions, events, of the whole chain.

const Web3 = require("web3");

const { INFURA_WSS_ENDPOINT } = process.env;

const web3Instance = new Web3(INFURA_WSS_ENDPOINT);

	.then((blockNumber) => console.log("Current block number: ", blockNumber));

To create a contract instance - ERC20: You can listen events and call methods of a given contract.

const Web3EthContract = require("web3-eth-contract");
const ContractABI = require("./ContractABI.json");

const { INFURA_WSS_ENDPOINT } = process.env;


const CONTRACT_ADDRESS = "0xa05F7df24D81438CB2306A07d1204967b48f20d2";

const contractInstance = new Web3EthContract(ContractABI, CONTRACT_ADDRESS);
	.on("data", (event) => console.log("Transfer: ", event))
	.on("changed", (changed) => console.log("Changed: ", changed))
	.on("error", (err) => console.log("Error: ", err.message, err.stack))
	.on("connected", (str) => console.log("Connected: ", str));

Repository on github: