Ethers.js is a compact Javascript library used for interacting with the Ethereum blockchain and other EVM compatible chains.
const { ethers } =require("ethers");// URL of the RPC for the CrossFi Testnet constproviderUrl="https://rpc.testnet.ms/";// Creating a provider to interact with the blockchainconstprovider=newethers.JsonRpcProvider(providerUrl);asyncfunctionmain() {// Getting the current block number as a test of the connectionconstblockNumber=awaitprovider.getBlockNumber();console.log(`Current block number: ${blockNumber}`);}main().catch((error) => {console.error("Error connecting to the blockchain:", error);});
Viem
Viem is a TypeScript library that offers type-safe modules for interacting with the Ethereum and other EVM compatible chains.