[SOLVED] Incorrect results for getTokenBalances address

Hello, I’m using getTokenBalances function to get user erc20s. It seemed to work alright so far, but recently we have encountered problem, when this endpoint returns incorrect data.

I’m calling this:
POST request URL: https://u3mhdofzmcp5.usemoralis.com:2053/server/functions/getTokenBalances

POST body:
{"chain":"mainnet","address":"0xd8d7ad6d6d3554a1f9472c3df567061e6af6aa3a"}

And result I get:
{"result":[]}


However this is incorrect, because at least WETH should be returned here, as you can see this address has balance > 0, when you try to call balanceOf function directly on the contract with this address. You can try it on Etherscan - https://etherscan.io/token/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2#readContract .

It returns following:
Screenshot from 2021-11-26 11-27-46

I think in this situation, the WETH should be returned from getTokenBalances endpoint, right? Do you have any idea why is this happening? Is Moralis node out of sync? Thanks for help and info:).

it looks like it should return some data, I don’t know why it doesn’t, we are going to investigate, thanks for reporting

I’m having a similar issue. I’m using the ethereum-boilerplate template, and things do not work as expected. For instance, when calling cegw5u2rkwtg.usemoralis.com:2053/server/functions/getTokenBalances, I receive {result: []} when calling for address 0x112bd956fd2d4bd00596c28f388a21eaf634082a and chain ** 0x13881**.
However, when using the api client, the correct result is returned.

What’s the difference between the server function of getTokenBalances and deep-index.moralis.io/api/v2/{address}/erc20? Is it the same issue as @microHoffman’s?

Edit: inexplicably, the correct response is now returned. I don’t really know what has changed, but will update if I find something

1 Like

it doesn’t looks like same issue, can you try to update/restart your server?

I think I found out why it does not recognize the asset - you are probably fetching only the Transfer events, right? And since deposit method on the WETH9 mainnet contract does not trigger this Transfer method, you do not recognize it as my asset. Do you think that could be the issue? I’ve just stumbled upon the same buggy behavior while i was myself trying to fetch the user erc20s from transfer events directly.

that could be a possible reason

we think that we solved the problem now

Thanks, just tested it and works:).