Search and Filter Tokens

Overview

This section details how to retrieve token balance using user wallet address and token IDs.

Properties

addresses

A list of addresses used to query tokens.

e.g.

[
    "0x2D2438C6281B5115733287fC279f854c868D3ee2",
    "0xFFFFFfFF00000000000000000000000000000417"
]

filters

An object of filters used to reduce the the amount of results returned. These filters are best used when looking up a specific token, or in conjuction with the genericTokenIds when using the amountRange filter.

e.g.

{
    "name": "Root",
    "symbol": "ROOT",
    "amountRange": ["0", "10000"]
}

Filter Types

Name

The name of the generic token.

Should be a string

e.g.

Root

Symbol

The symbol of the generic token.

Should be a string

e.g.

ROOT

Amount Range

The balance amount of the generic token held by the addresses given.

Should be an array of string numbers. The first number represents the minimum and the second number represents the maximum. The second number can be left out if the result should not be bound by the maximum.

e.g.

[ "0", "100000" ]

Usage

import { useGenericTokenBalances } from '@futureverse/asset-register-react/v2'
import { ChainAddress, GenericTokenId } from '@futureverse/asset-register/types'

export const GenericTokenBalances = () => {
  const { genericTokenBalances } = useGenericTokenBalances({
    addresses: ['0x8bb9a0fff4ff087a5de85ba0e89a5d376ce2a595' as ChainAddress],
    filters: {
      name: "Root",
      symbol: "ROOT",
      amountRange: ["0", "10000"]
    },
  })

   return (
    <div>
      {genericTokenBalances?.map((genericTokenBalance) => {
        return (
          <div>
            <div>{genericTokenBalance.genericToken.chainId}</div>
            <div>{genericTokenBalance.genericToken.location}</div>
            <div>{genericTokenBalance.owner.address}</div>
            <div>{genericTokenBalance.amount}</div>
          </div>
        )
      })}
    </div>
  )
}

Last updated

© 2023 -> ♾️