matter-labs / matter-labs/block-explorer

API endpoint /api/account/addresstokenbalance is returning ERC721s

Open
#504 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
139
Forks
145
Avg merge
8h 3m
Merged PRs (30d)
3

Description

🐛 Bug Report

Getting the token balance of ERC20s for an address returns a list that includes ERC721s.

📝 Description

The balanceService.getBalances(address) is returning a list of ERC20s along with ERC721s

🔄 Reproduction Steps

https://block-explorer-api.mainnet.zksync.io/api?module=account&action=addresstokenbalance&address=0x0f6bfc4C284e489B404715B3F2610b0eb50FdE35

as well as:

https://block-explorer-api.mainnet.zksync.io/address/0x0f6bfc4C284e489B404715B3F2610b0eb50FdE35

Checking the return data, the last item in the list is "empty" data for a token with a quantity of 1.

{
      // Contract address is for CyfrinFoundryCourseNft 
      "TokenAddress": "0xBbA202c6DA89646F13C11a63C4aF182E4fFd4c2e",
      "TokenName": "",
      "TokenSymbol": "",
      "TokenQuantity": "1",
      "TokenDivisor": ""
  }
🤔 Expected Behavior

Only ERC20s listed for an address.

😯 Current Behavior

ERC20 and ERC721 are listed

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the /api/account/addresstokenbalance endpoint to balanceService.getBalances(address), then compare its returned items with the address page response. Reproduce the example request and verify that the result contains only ERC20 tokens, excluding the ERC721 entry with TokenQuantity "1" and empty metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.