Its not showing all ERC20 tokens in my wallet

Hey there I am trying to fetch all ERC20 tokens. It was working but then i transfered it to another address. Now when I try connecting to a dfiferent address with the ERC20 usdt token its not showing up. Also tried with different accounts.
I updated my moralis server and tried literally all.

            const tokens = await Moralis.Web3.getAllERC20();
            console.log(tokens);

this doesn’t depend on the server, it is only an API request

latest function name from latest sdk version is getTokenBalances
https://docs.moralis.io/moralis-dapp/web3-api/account#gettokenbalances

if you have a case when it doesn’t return the expected data, you can give more details about that specific case

1 Like

yeah i tried get toke balance too. It gives me an empty array. I have 7$ in eth and 10$ in usdt. I also set some allowances to that token if makes any effect.
I get this Array [] . Thats the address 0x853a0CB61a3A3BDc9169B4B77B7a3c91834F4e13

what do you need from me else ? I am not using react.
<script src="https://npmcdn.com/moralis/dist/moralis.js"></script>

https://deep-index.moralis.io/api/v2/0x853a0CB61a3A3BDc9169B4B77B7a3c91834F4e13/erc20?chain=eth

=>

[
  {
    "token_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "name": "Tether USD",
    "symbol": "USDT",
    "logo": "https://cdn.moralis.io/eth/0xdac17f958d2ee523a2206206994597c13d831ec7.png",
    "thumbnail": "https://cdn.moralis.io/eth/0xdac17f958d2ee523a2206206994597c13d831ec7_thumb.png",
    "decimals": 6,
    "balance": "15000000"
  }
]

this is equivalent to getTokenBalances

invalid key :frowning:

what did you try? where from is that error?

i got the api key now. Where do i have to put it. Whats the value you guys looking for in the body

const tokens = await fetch(`https://deep-index.moralis.io/api/v2/0x853a0CB61a3A3BDc9169B4B77B7a3c91834F4e13/erc20?chain=eth`, this.requestOptions)

you don’t have to use the api key, that is only an alternative way to do it

you can use directly balances = await Moralis.Web3API.account.getTokenBalances({'address': '0x853a0CB61a3A3BDc9169B4B77B7a3c91834F4e13'});

i used the api key. Without it wasnt working

try the above code that doesn’t require to use the api key

yeah its working too. But why wasnt it working. Thats really weird

also how can I check if its erc20 ? It only shows the tokens

it only shows erc20 tokens

hey I got another problem. When I use that function it shows me that I have Luna tokens eventhough I have never ever used any Luna tokens ?

            const tokens = await fetch(`https://deep-index.moralis.io/api/v2/${this.walletAddress}/erc20?chain=eth`, this.requestOptions)
            .then(resp => resp.json());

You can check in etherscan to see if it says the same thing or not for they address.

Ty for reply.
Why is It doing this ? Any way to prevent it ?

I don’t know what is the problem now. Is that token present in etherscan too for that wallet address?