Chain Balances

This function of the SDK provides developers with the method required to access and display the balances of all tokens held in an Externally Owned Account (EOA) wallet on a single blockchain.

Expected parameters

fetchBalances accepts the following parameters:

  • eoaAddress: The address whose balances are required to be fetched.

  • chainId: The chain ID of the current network.

  • tokenAddresses[OPTIONAL]: Array of the token addresses whose balances will be fetched.

  • fetchBalancesOnly: Default is set to true. If set to false then more details of the tokens are fetched.

NOTE:

  • If the tokenAddresses are not provided, then balances of all the tokens within the EOA will be fetched.

  • fetchBalancesOnlyis default to true.

Function Call

let balances = await aarcSDK.fetchBalances(
  "EOA_ADDRESS",
  137, // Chain id of the network
  true, // fetch balances only
  ["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] // [OPTIONAL] array of specific token
);

Response

When fetchBalancesOnly is 'true':

{
  "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee": number,
  "0xanotherTokenAddressHere": number
}

When fetchBalancesOnly is 'false':

{
  "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee": {
                "decimals": number,
                "name": string,
                "symbol": string,
                "token_address": string
                "logo": string,
                "native_token": boolean,
                "type": string,
                "is_spam": boolean,
                "balance": string,
                "usd_price": boolean
  },
  "0xanotherTokenAddressHere": {
                "decimals": number,
                "name": string,
                "symbol": string,
                "token_address": string
                "logo": string,
                "native_token": boolean,
                "type": string,
                "is_spam": boolean,
                "balance": string,
                "usd_price": boolean
  }
}


Support

If you face any trouble, feel free to reach out to our engineers in the Telegram support group.

Last updated