[SOLVED] How to check if the user has Erc20 Token

Hi, I want to check if the user already has ERC20 token in their metamask

So I just create a function to auto import the token
but I need a condition to check :

  • if the user already has the ERC20, no need to execute the auto import function
  • if not, execute the function

so I need to check if the user already has the token, how to achieve this using Moralis?

Thank you!

You can use getWalletTokenBalances API to get all token balances for an address.

If you use the token_addresses param as described on that page, you can filter the results down to a specific token address(es).

Thank you! appreciate your answer