Avalanche SDK Client - v0.0.4-alpha.14
    Preparing search index...

    Function getAllBalances

    • Get the balances of all assets controlled by given addresses.

      Type Parameters

      • chain extends undefined | Chain

      Parameters

      Returns Promise<GetAllBalancesReturnType>

      The balances of all assets. GetAllBalancesReturnType

      avm.getAllBalances is deprecated in AvalancheGo, and AvalancheGo plans to remove it in an upcoming release. Use getUTXOs instead: page through all UTXOs, decode each with getUtxoFromBytes from @avalanche-sdk/client/utils, and for each asset add the amounts of the secp256k1fx transfer outputs that only this address owns (threshold 1) and whose locktime has passed. avm.getAllBalances skips all other outputs.

      import { createAvalancheCoreClient } from '@avalanche-sdk/client'
      import { avalanche } from '@avalanche-sdk/client/chains'
      import { getAllBalances } from '@avalanche-sdk/client/methods/xChain'

      const client = createAvalancheCoreClient({
      chain: avalanche,
      transport: {
      type: "http",
      url: "<url>",
      },
      })

      const balances = await getAllBalances(client, {
      addresses: ["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"]
      })