Skip to Content
Avail Nexus is now live! Check out our docs to get started.
NexusNexus SDK ReferenceNexus (Headless)Unified Balance

getUnifiedBalances() & getUnifiedBalance()

SET UP THE SDK BEFORE YOU START:

  1. You can find the SDK setup instructions in the Quickstart page.
  2. We also created a tutorial to make it easier to understand how devs need to initialize the Nexus SDK in their project.

Use these functions to fetch consolidated token balances across all supported chains in one call.

Note: Check out the API reference for a full list of supported tokens and chains.

Method signatures

Typescript
async getUnifiedBalances(): Promise<UserAsset[]> async getUnifiedBalance(symbol: string): Promise<UserAsset | undefined>

Parameters

  • symbol (string, required for getUnifiedBalance): Token symbol, e.g. 'USDC' | 'USDT' | 'ETH'.

getUnifiedBalances()

Fetches the unified balance of all tokens across all chains for a user.

Typescript
// No parameters required await sdk.getUnifiedBalances(): Promise<UserAsset[]>

getUnifiedBalance(symbol)

Fetches the unified balance of a specific token across all chains for a user.

Typescript
// Takes a token symbol parameter await sdk.getUnifiedBalance(symbol: string): Promise<UserAsset | undefined>

Example

Here are some minimal examples of how to use the functions to fetch the unified balance of a user:

Typescript
// Get all balances across chains const allBalances = await sdk.getUnifiedBalances(); console.log('All balances:', allBalances); // Get balance for specific token const usdcBalance = await sdk.getUnifiedBalance('USDC'); console.log('USDC balance:', usdcBalance);

Return Value

  • getUnifiedBalances(): Returns Promise<UserAsset[]> - Array of UserAsset class instances
  • getUnifiedBalance(symbol): Returns Promise<UserAsset | undefined> - Single UserAsset instance or undefined
Typescript
class UserAsset { value: UserAssetDatum; // The actual data get balance(): string; // Getter for balance } // The underlying data structure for `UserAsset` export type UserAssetDatum = { abstracted?: boolean; balance: string; balanceInFiat: number; breakdown: { balance: string; balanceInFiat: number; chain: { id: number; logo: string; name: string; }; contractAddress: `0x${string}`; decimals: number; isNative?: boolean; universe: Universe; }[]; decimals: number; icon?: string; symbol: string; };
Last updated on