Sign Up
Skip to content

Tokens Balances

In the following examples, we're going to use the GetTokenBalances method from Sequence Indexer Gateway:

GetTokenBalances

  • Request: POST /rpc/IndexerGateway/GetTokenBalances
  • Content-Type: application/json
  • Body (in JSON):
    • chainIds ([]int - optional) -- return results only for the chains that match the given ID.
    • networks ([]string - optional) -- return results only for the chains that match the given names.
    • accountAddress (string) -- the wallet account address
    • contractAddress: (string -- optional) -- the token contract address
    • tokenID: (string -- optional) -- the ID of the token
    • includeMetadata (boolean - optional - default: false) -- toggle token metadata to be included in the response
    • includeCollectionTokens (boolean - optional - default: true) -- toggle to represent ERC721 / ERC1155 tokens as a single summary item in the response
    • metadataOptions (object - optional) -- additional options for metadata
      • verifiedOnly (boolean - optional) -- return only contracts which are 'verified' to help reduce spam
      • unverifiedOnly (boolean - optional) -- return only contracts which are 'unverified'
      • includeContracts ([]string - optional) -- list of specific contract addresses to always be included, even if verifiedOnly is enabled.

These examples are based on the Fetch All Tokens example for Indexer.

Get token balances and metadata from an account on multiple Ethereum networks

Example: Retrieve token balances, along metadata for the 0x8e3E38fe7367dd3b52D1e281E4e8400447C8d8B9 account across all chains.

Curl
curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-Access-Key: AQAAAAAAAF_JvPALhBthL7VGn6jV0YDqaFY" \
  https://indexer.sequence.app/rpc/IndexerGateway/GetTokenBalances \
  -d '{
    "accountAddress": "0x8e3E38fe7367dd3b52D1e281E4e8400447C8d8B9", 
    "includeMetadata": true,
    "metadataOptions": {
      "verifiedOnly": true
    }
  }'

Fetch token IDs, balances and metadata of ERC721 and ERC1155 collections.

Example: fetch token balances for a specific account and token contract on the Polygon network

Curl
curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-Access-Key: AQAAAAAAAF_JvPALhBthL7VGn6jV0YDqaFY" \
  https://indexer.sequence.app/rpc/IndexerGateway/GetTokenBalances \
  -d '{
    "chainIds": [137],
    "accountAddress": "0x8e3E38fe7367dd3b52D1e281E4e8400447C8d8B9",
    "contractAddress": "0x631998e91476DA5B870D741192fc5Cbc55F5a52E",
    "includeMetadata": true,
    "metadataOptions": {
      "verifiedOnly": true
    }
  }'