Contract Token Balance API

Hi Team,

This API returns the token balance of the Wallets only but not the contract

@moralisweb3/common-evm-utils
const response = await Moralis.EvmApi.token.getWalletTokenBalances({

Is there a different API/end-point to get the ERC-20 token balance of any contract?

Regards

Hey @Shahidma58,

Thanks for reaching out to us :grinning_face_with_smiling_eyes:

Can you clarify what do you mean by ERC20 token balance of any contract? If you are referring to the ERC20 token balance that a contract address holds, then you just need to use that API and provide the contract address as the input parameter.

Hi,

Yes, you understood the issue correctly.

const address = β€œ0x80d62e372b8812086873bf8a654b49349dfad909”; // Contract

const response = await Moralis.EvmApi.token.getWalletTokenBalances({

But this returns the wallet token balances but not the contract balance

results null

but

const address = β€œ0x5c765DdD5D71192c02061b3E01F4281b32d88824”;

returns the following results mean the contract has a balance

[

{
token_address: β€˜0x0d92913095942f168d139b12a88fc8f42f8f96f6’,
name: β€˜Reward’,
symbol: β€˜RT’,
logo: null,
thumbnail: null,
decimals: 18,
balance: β€˜10000000000000000000000000’
},
{
** token_address: β€˜0x80d62e372b8812086873bf8a654b49349dfad909’,
name: β€˜Reward’,
symbol: β€˜RT’,
logo: null,
thumbnail: null,
decimals: 18,
balance: β€˜9999998000000000000000000’**
},
{
token_address: β€˜0xc877939ddad037bce1abe327cd7f7524e984e4d7’,
name: β€˜Reward’,
symbol: β€˜RT’,
logo: null,
thumbnail: null,
decimals: 18,
balance: β€˜10000000000000000000000000’
}
]

So, feel there could be some change in this

const response = await Moralis.EvmApi.token.getWalletTokenBalances

Regards,

–

On what chain it happens?
If that contract address has too many ERC20 tokens then it will not work

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.