How to check the balance of ERC-20 tokens in the Wallet? A comparison and evaluation of these 3 API tools.

robot
Abstract generation in progress

Problem Scenario

Want to check which tokens are in a specific Ethereum wallet? You can directly open the wallet software, but what if you need to check someone else's wallet (for example, regulatory departments, exchange risk control), or if you need to automate bulk queries? That's when you need to rely on the API.

Today we will evaluate three mainstream Web3 tools: Chainbase, Alchemy, and Moralis - let's see which one is the most user-friendly.

Option 1: Chainbase (Fastest to Get Started)

Advantages: The process is the simplest, optimized specifically for blockchain data.

Core Steps:

  1. Register account → Get API key
  2. Call the getAccountTokens interface, passing in the chain ID and wallet address.
  3. One line of code to get all ERC-20 balances

Code Example (JavaScript): Directly use Fetch or Axios to send an HTTP request to Chainbase, passing in Vitalik's wallet address, and receive the specific amounts of tokens such as UNI, dYdX, etc. in seconds.

Output: Contract address + token balance, can be precise to a specific token.

Solution 2: Alchemy (Most Flexible)

Advantages: Most comprehensive features, most detailed data

Core Steps:

  1. Node + NPM Environment Configuration
  2. Create an Alchemy application and obtain the API Key
  3. Use the getTokenBalances method to check the balance
  4. Use getTokenMetadata to supplement token name, symbol, precision, and other information.

Extra Capability: The returned balance is in hexadecimal format and needs to be converted to a human-readable number. Alchemy allows filtering of zero balance tokens and supports custom scripts to link two methods.

Output: Complete token information (Name/Symbol/Logo URL/Decimal Precision) + Balance.

Solution 3: Moralis (Most out-of-the-box)

Advantages: Enterprise-level stability, minimal one-liner code.

Core Steps:

  1. Install Node.js and create a Moralis account.
  2. Copy the API key from Settings > Secrets
  3. Call the getWalletTokenBalances endpoint, just pass the address + chain name.
  4. Directly output JSON, including complete information of tokens such as APE, WETH, etc.

Output: JSON format, including contract address, token name, symbol, precision, balance.

Three-party Comparison

| Tool | Ease of Use | Functionality Completeness | Output Friendliness | Most Suitable | |------|--------|---------|---------|--------| | Chainbase | The simplest | Medium | Medium | Quick query | | Alchemy | Medium | Most Comprehensive | Good (requires manual optimization) | Professional Development | | Moralis | The simplest | Complete | The best | Enterprise applications |

Core Differences

  • Chainbase: Focused on on-chain data, the API design is most direct.
  • Alchemy: Platform layer approach, providing two methods: SDK + Fetch, requires linking multiple methods by oneself.
  • Moralis: Integrated service with out-of-the-box results, including token logos and other additional data.

Selection Suggestions: Use Moralis for quick verification; choose Alchemy for in-depth customization; select Chainbase for data query orientation.

ETH-2.82%
UNI-7.4%
DYDX-8.81%
APE-6.65%
View Original
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • Comment
  • Repost
  • Share
Comment
Add a comment
Add a comment
No comments
  • Pinned