Using getTokenBalances() with avalanche?

Is this supported?

     const options = { chain: 'avalanche' };
    const balances = await Moralis.Web3API.account.getTokenBalances(options);

When I run this code I get back:

asyncToGenerator.js?1da1:6 Uncaught (in promise) {code: 141, error: 'Invalid chain'}

Yep, it should be just tried it on my end.
Ran this snippet:

   const b = await Moralis.Web3API.account.getTokenBalances({
                chain: "avalanche",
              });
              console.log(b);

To use the .account make sure you are first signed in. It could also be the version. Are you connecting via URL to SDK, or are you using a npm library, maybe the downloaded library needs to be updated.

2 Likes

0xdefa4e8a7bcba345f687a2f1456f5edd9ce97202

Thanks this is working now. Iā€™m not sure what was wrong before but my code is working ok today.

2 Likes