A Web3 library is a tool that allows developers to interact with blockchains. These libraries provide an easy-to-use interface for developers to build decentralized applications (DApps) and interact and retrieve data from a blockchain.
npm install web3
pip install web3
Web3
class and passing in the URL of an Ethereum node deployed with Chainstack. For example:
const { Web3 } = require("web3");
const node_url = "CHAINSTACK_NODE_URL";
const web3 = new Web3(node_url);
web3.js
V4, numeric values are returned as BigInt
, identifiable by the n suffix (e.g., 247n
). This change ensures high-precision handling of large integers in blockchain applications. Remember to either convert these values to standard integers or adapt other values to BigInt when performing mathematical operations.ChainstackProvider
. You can create a ChainstackProvider
instance and connect to Ethereum Mainnet (mainnet), Arbitrum (arbitrum), BNB Smart Chain Mainnet (bnb), Polygon (matic).
For example:
const ethers = require("ethers");
// Create a ChainstackProvider instance for Ethereum mainnet
const chainstack = new ethers.ChainstackProvider("mainnet"); // Swap 'mainnet' for 'arbitrum', 'bnb' , and 'matic'
client
instance with a transport
. This can be done with createPublicClient
and passing in the URL of an Ethereum node deployed with Chainstack. For example:
import { createPublicClient, http } from 'viem';
const publicClient = createPublicClient({
transport: http('CHAINSTACK_NODE_URL')
});
Web3
class and passing in the URL of an Ethereum node deployed with Chainstack. For example:
from web3 import Web3
node_url = "CHAINSTACK_NODE_URL"
web3 = Web3(Web3.HTTPProvider(node_url))
Was this page helpful?