Moralis icon

Moralis

Interact with Moralis Web3 APIs for blockchain data, NFTs, tokens, and DeFi

Wallet → Get Token Balances

AI-generated

Overview

This node operation retrieves the ERC20 token balances of a specified wallet address on a selected blockchain network. It is useful for users who want to monitor or analyze the token holdings of a wallet across different blockchains such as Ethereum, Polygon, BSC, and others. For example, a user can input a wallet address and select the blockchain to get a list of all ERC20 tokens held by that wallet along with their balances.

Use Case Examples

  1. A DeFi analyst wants to track the token balances of a wallet on the Ethereum blockchain to assess portfolio distribution.
  2. A developer building a wallet management app needs to fetch token balances for user wallets on multiple chains like Polygon and Avalanche.

Properties

Name Meaning
Chain The blockchain network to query for the wallet's token balances. Options include Ethereum, Polygon, BSC, Arbitrum, Avalanche, Base, and Optimism.
Wallet Address The wallet address whose ERC20 token balances are to be retrieved. This is a required string input.
Additional Fields Optional parameters to customize the query, including limit on number of results, pagination cursor, whether to include metadata, and number format (decimal or hex).

Output

JSON

  • json - The JSON response containing the token balances data retrieved from the Moralis API, including token details and balances.
  • operation - The operation performed, here it is 'getTokenBalances'.
  • resource - The resource type, here it is 'wallet'.
  • chain - The blockchain network queried.
  • timestamp - The timestamp when the data was retrieved.

Dependencies

  • Moralis API key credential required for authentication to access Moralis Web3 API endpoints.

Troubleshooting

  • Common issues include invalid or missing wallet address, unsupported blockchain network selection, or exceeding API rate limits.
  • Error messages may indicate network errors, invalid API key, or no data found for the given wallet address. Ensure the wallet address is correct and the API key is valid.
  • If pagination is used, ensure the cursor parameter is correctly handled to fetch subsequent pages.

Links

Discussion