How to get wallet balances on Solana

Fetch SOL balance, all token holdings, or check a specific token. Copy the code snippets below to use in your own project.

Which method should I use?

Choose the right approach based on what you need. Each method below includes working code you can copy directly into your project.

Just SOL balance

Use getBalance for the fastest way to check native SOL. Returns lamports which you divide by 1e9.

All tokens + SOL

Use getAssetsByOwner with showNativeBalance to get everything in one call with metadata and prices.

One specific token

Use getTokenAccounts filtered by mint to check USDC, USDT, or any SPL token balance efficiently.

API Notes

  • getBalance: Standard RPC method. Returns lamports (1 SOL = 1 billion lamports). Divide by 1e9 for SOL.
  • getAssetsByOwner: DAS API returns all tokens with metadata. Enable showNativeBalance: true for SOL.
  • getTokenAccounts: DAS API filtered by mint address. Best for checking specific token holdings without fetching all assets.