Use ethers with the ChainstackProvider
to call smart contract functions.
Overview
ChainstackProvider
to call smart contract functions, such as fetching balance and symbol.Environment setup
ethers.js
library.npm install ethers
Initialize ChainstackProvider
index.js
, import the ethers.js library, and initialize a new ChainstackProvider
instance.Check the docs to find what chains are supported by ChainstackProvider
.ChainstackProvider docsInitialize the ABI and smart contract instance
symbol()
and balanceOf()
functions.This specific example retrieves the transfer logs for the APE token, but you can use any ERC-20 token smart contract address.Function for balance and token symbol
eth_call
under the hood.This function also converts the response and logs it to the console.Set up account address and call the function
Run the script
node index
.