Failure to find ERC20 Balance

Hello!

I am trying to call getERC20 on the current user for a specific ERC20, however the symbol isn’t recognized. When I call getAllERC20 the token appears.

    const eViralBalance = await Moralis.Web3.getERC20({chain: 'eth', symbol: "eViral 🧬"});
    console.log(eViralBalance);

This returns the following error:

However when I call getAllERC20 and log to console the token displays:

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

*** PIC IN REPLY***

Is there a specific way to find balances for tokens with emojis? I’m not having any luck. Also is there a way to find the token by contract address rather than symbol?

Thank you for any help resolving this!
Sol

Being new I could only include 1 pic in the first post here is the token from getAllERC20

This is a bug. Will fix this. Thanks for reporting it!

2 Likes

Special character causing some issue, we will fix in the next day or so

1 Like

Thank you for the response and for looking into this

Thank you Ivan. Would it not be a good idea to allow to pass the parameter tokenAddress into the getERC20 to specify the token’s contract address? I have seen there are a couple of duplicate token symbols and that may cause issues as well besides emojis.

Something like this:

const eViralBalance = await Moralis.Web3.getERC20({chain: 'eth', tokenAddress: '0x7cec018ceef82339ee583fd95446334f2685d24f'});

Thank you for your time. Exited to build with Moralis!

1 Like

This should be fixed in an upcoming Moralis Sever version. The actual issue was case sensitivity, the function call was converting to upper case for convenience, but there are token symbols where case matters. For example, “Inu” and “INU” are different tokens.

This is a good suggestion. Will add a param tokenAddress, otherwise there is no way to get the balance for different tokens with exactly the same symbol.

1 Like

If I can make one more suggestion that seems like it would be easy to integrate soon, could you consider implementing a check for a user’s specific NFT token balance using a contract address and tokenID for parameters? This would be useful for ERC1155’s especially from Rarible. Rarible uses contract 0xd07dc4262BCDbf85190C01c996b4C06a461d2430 to create ERC1155’s. So if I wanted to check if someone held a specific ERC1155 NFT (in this example the tokenID is 625312) made on Rarible I could call something like the following:

const getNFTBalance = await Moralis.Web3.getNFTs({ chain: 'eth', NFTaddress: "0xd07dc4262BCDbf85190C01c996b4C06a461d2430 ", tokenID: "625312" });

Thank you!

1 Like

Great idea thanks we will share with the team!

1 Like

Case sensitivity issue fixed and tokenAddress param added in Moralis Server version 0.0.238! Please update your server instance to the latest version and let us know if you experience any other issues. :raised_hands:

Hrm it should only return the ETH balance if no symbol or tokenAddress option was supplied. Will look into this.

2 Likes

There was an issue on the SDK side. Should be fixed now. Update to the latest Moralis SDK version (0.0.30) and do a hard refresh in the browser. If you’re using the CDN link that always points to the latest version the refresh should be enough. Let us know if you experience any further issues.

FYI the CDN link is

<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
2 Likes

FYI this can be done already for ETH with the Deep Index API. Check out the swagger docs on your Moralis server on the Deep Index API page.

2 Likes