Chain Balances

fetchBalances 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:

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':

{
  "code": 200,
  "data": [
    {
      "tokenAddress": "0x...eee",
      "balance": number
    },
    {
      "tokenAddress": "0x...000",
      "balance": number
    },
  ],
  "message": "success"
}

When fetchBalancesOnly is 'false':

{
  "code": 200,
  "data": [
    {
      "decimals": number,
      "native_token": boolean,
      "name": string,
      "symbol": string,
      "token_address": 0xstring,
      "balance": string,
      "type": string,
      "permit2Allowance": string,
      "permitExist": boolean,
      "nft_data": [
         {
            "image": string;
            "tokenId": string;
         }
      ]
    },
    {
      "decimals": number,
      "native_token": boolean,
      "name": string,
      "symbol": string,
      "token_address": 0xstring,
      "balance": string,
      "type": string,
      "permit2Allowance": string,
      "permitExist": boolean,
      "nft_data": [
         {
            "image": string;
            "tokenId": string;
         }
      ]
    }
  ],
  "message": "success"
}

Support

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

Last updated