Skip to main content

Documentation Index

Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt

Use this file to discover all available pages before exploring further.

When a user connects multiple wallets — for example, an EVM and a Solana account — you often want to display each balance side by side. This guide composes getWalletAccounts with getBalance to fetch native balances across every connected account.

Usage

import { getWalletAccounts, getBalance } from '@dynamic-labs-sdk/client';

const getAllBalances = async () => {
  const walletAccounts = getWalletAccounts();

  const results = await Promise.all(
    walletAccounts.map(async (walletAccount) => {
      const { balance } = await getBalance({ walletAccount });
      return {
        address: walletAccount.address,
        chain: walletAccount.chain,
        balance,
      };
    })
  );

  results.forEach(({ address, chain, balance }) => {
    console.log(`${chain} ${address}: ${balance}`);
  });

  return results;
};

Notes

  • getBalance returns the native token balance on each account’s currently active network. For ERC-20 / SPL token balances, use getBalances (single network) or getMultichainBalances (multiple chains for one account).
  • Calls run in parallel via Promise.all — slowest RPC determines the wait time. If one chain is unreliable, wrap each call in try/catch to keep the others from failing the whole batch.
  • Only verified wallet accounts are persisted in the user’s Dynamic record; unverified accounts are session-only. Both kinds appear in getWalletAccounts() — filter by walletAccount.verifiedCredentialId if you want to display only verified ones.