Can you use ethers.js with the Avalanche network, Polygon network, and Fantom Opera?

1.7k Views Asked by At

I am trying to use ethers.js to check the balances of wallets on evm compatible side chains.

token.balanceOf(address)

keeps giving me 0. I have changed the rpc, contract abis, and contract addresses to their respective chains. Am I missing something or is there an easier way to do this?

1

There are 1 best solutions below

0
On

Make sure you are connected to a node related to the network where the token is located. Make sure to initiate the token instance with abi and contract address first. Then you should be able to call the functions such as .balanceOf