Fake Eth in Test Network Not Showing in Balances

Hi all,
I am currently on the “Metamask Balances” lesson in the [2021 JavaScript Programming for Blockchain Developers].

I have 0.3 ETH in my Metamask under the Rinkeby Test Network however I am unable to see this in my balance when I console.log balances.

This is my current code for which I get an empty array. Appreciate any help!

async function getStats() {
    const balances = await Moralis.Web3API.account.getTokenBalances({chain: 'polygon'});
    console.log(balances);
}
1 Like

I am agree your information is very interesting . and good question .but i am not idea.

Hey @Eleanor_Tay, hope you are well.

Take a look into the docs for getTokenBalances, you have specified the polygon chain, instead rinkeby.
https://docs.moralis.io/moralis-server/web3-sdk/account#gettokenbalances

Check the lookup values for which chain are supported and the code value of it.
https://docs.moralis.io/moralis-server/web3-sdk/intro

So it should be:

async function getStats() {
    const balances = await Moralis.Web3API.account.getTokenBalances({chain: 'rinkeby'});
    console.log(balances);
}

Hope it helps.

Carlos Z

Hi Carlos,
Thanks for reaching out. I unfortunately still get a blank array even after changing my chain to rinkeby

1 Like

Indeed, although in the docs said that the address is optional, apparently is required.

Try with:

async function getStats() {
    const balances = await Moralis.Web3API.account.getTokenBalances({chain: 'rinkeby', address:'YOURADDRESSHERE'});
    console.log(balances);
}

Carlos Z

Hey All

I’m stuck on this too.

const paramaters = {chain: 'eth', address: '0x3...MYADDRESS...'};
const balances = await Moralis.Web3API.account.getTokenBalances(paramaters);
console.log(balances);

My results are continually ‘[ ]’ in the console.log

I have .0077 ETH in my Ethereum Mainnet account.

Shouldn’t this show up when I console log?