getBalancesForBridge()
SET UP THE SDK BEFORE YOU START:
- You can find the SDK setup instructions in the Quickstart page.
- We also created a tutorial to make it easier to understand how devs need to initialize the Nexus SDK in their project.
Use the getBalancesForBridge() function to fetch token balances that can be used in bridge operations across all supported chains in one call.
Note: Check out the API reference for a full list of supported tokens and chains.
Method signature
Typescript
getBalancesForBridge(): Promise<UserAsset[]>Deprecated: getUnifiedBalances() has been replaced by getBalancesForBridge().
If you need tokens that can be used for swaps, use getBalancesForSwap().
Parameters
- None
Example
Here is a minimal example of how to use the getBalancesForBridge() function to fetch the balances accessible by the bridge operations of a user:
Typescript
// Get all balances accessible by the bridge operations of a user
const bridgeBalances = await sdk.getBalancesForBridge();
console.log('Bridge balances:', bridgeBalances);Return Value
getBalancesForBridge(): ReturnsPromise<UserAsset[]>- Array ofUserAssetobjects.
Typescript
export type UserAsset = {
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