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

Viewed 1297

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 Answers

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

Related