The client to use. AvalancheCoreClient
The addresses to get balances for. GetAllBalancesParameters
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"]
})
Get the balances of all assets controlled by given addresses.