Duplicate Token Balances

Hi, I’ve used the ETH network instead of Polygon because I have no balances in Polygon Metamask. The output I am getting is a duplicate token balance for one coin that I have and no data fetched for the actual ETH I have in the wallet. Why could this be happening? I have coded exactly how I see the instructor code the project. My output and getStats() function are below.

(2) [{…}, {…}]
balance: "1085471724297161"
decimals: "9"
logo: null
name: "FLOKI"
symbol: "FLOKI"
thumbnail: null
token_address: "0xcf0c122c6b73ff809c693db761e7baebe62b6a2e"
[[Prototype]]: Object
balance: "1085471724297161"
decimals: "9"
logo: null
name: "FLOKI"
symbol: "FLOKI"
thumbnail: null
token_address: "0x43f11c02439e2736800433b4594994bd43cd066d"
[[Prototype]]: Object
length: 2
[[Prototype]]: Array(0)
async function getStats () {
      const balances = await Moralis.Web3API.account.getTokenBalances();
      $tokenBalanceTBody.innerHTML = balances.map( (token, index) => `
            <td>${tokenValue(token.balance, token.decimals)}</td>

Note the two FLOKI tokens have different addresses, I’d suggest googling those addresses.

Regarding ETH, maybe the SDK developers can help you further, but the difficulty is that obviously, you won’t be in a position to share your metamask login with them for debugging due to your own security. I haven’t reproduced anything similar.

Okay, just in case, who are the SDK developers I could ask about it? Thanks Zsolt, Andrew

This seems like a very vital feature, so before purchasing further programming, this is definitely something I would want to have resolved. The Moralis SDK is used in most of the other trainings too, I assume. Thanks, Andrew

1 Like

@thecil, SDK calls are a black-box for me and the post doesn’t have dev tools logs/details on the ajax calls submitted. Could you please let us know where to channel this?

1 Like

Hello guys, hope you are ok.

Now the sdk does not have any filter or something like it when it get all the tokens, if an address does have a balance on a contract Address, the sdk will add it to your token balances, so in few words, you do have 2 tokens which share the name, but their different on their contract address.


If you need to get the ETH balance that your wallet have, you need to call this function.

Keep in mind that getNativeBalance return the native balance of an account whitin a network (you can use it for polygon or bsc).

While getTokenBalances returns an array of all the tokens that the address have on that network.

You can get all the information of an account by calling each method, here is an example, but just to give you an idea.

    // verify Moralis current user
    const isUser = async() => {
        const user = Moralis.User.current()
        // initialize ethersjs library
        const ethers = Moralis.web3Library
        // A Web3Provider wraps a standard Web3 provider, which is
        // what MetaMask injects as window.ethereum into each page
        const provider = new ethers.providers.Web3Provider(window.ethereum)
        const network = await provider.getNetwork()
        const balance = await Moralis.Web3API.account.getNativeBalance({chain:network.name});
        const tokens = await Moralis.Web3API.account.getTokenBalances({chain:network.name});
        const nfts = await Moralis.Web3API.account.getNFTs({chain:network.name});
            // update user storage values
            User.update(value => {
                value = {
                    id: user.id,
                    address: user.attributes.ethAddress,
                    network: network.name,
                    balance: balance.balance,
                    tokens: tokens,
                    nfts: nfts,
                return value;

Hope this helps.

Carlos Z

1 Like

i am just starting with javascript but I don’t get past the first lesson of “HELLO MORALIS”
I downloaded the visual studio code 2 on my MacBook Air, but I don’t have the things like in the video. it all the time said the things from zsh: command not found
I really excited to start coding, can somebody help me please.
i don’t have command prompt on my screen. see picture

xaviervermeirsch@MacBook-Air-van-xavier MacOS % server.use
zsh: command not found: server.use
xaviervermeirsch@MacBook-Air-van-xavier MacOS % cd/c/WebDev

zsh: no such file or directory: cd/c/WebDev
xaviervermeirsch@MacBook-Air-van-xavier MacOS %
xaviervermeirsch@MacBook-Air-van-xavier MacOS %

this is my screen and everything the lesson does I try but it always says “no such file or directory” what should I do

By the way, thanks, I was able to make a work-around for the token balances using the getNative function. I appreciate the help! Blessings, Andrew