getTokenAccountBalance — Solana RPC Method
getTokenAccountBalance returns the token balance of a specific SPL Token account. The response includes both the raw amount (in the token’s smallest denomination) and a human-readable formatted value.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pubkey | string | Yes | Base-58 encoded public key of the SPL Token account. |
commitment | string | No | processed, confirmed, or finalized. Default: finalized. |
Request
curl -X POST https://api.mainnet-beta.solana.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountBalance",
"params": [
"FYjTtQvMC8Sn4fGPVZNKKhjrfGfgqAqkSAdBx2Xp7Phm"
]
}'
TypeScript (@solana/kit)
import { createSolanaRpc, address } from "@solana/kit";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const balance = await rpc
.getTokenAccountBalance(address("FYjTtQvMC8Sn4fGPVZNKKhjrfGfgqAqkSAdBx2Xp7Phm"))
.send();
console.log(`Amount: ${balance.value.uiAmountString}`);
console.log(`Decimals: ${balance.value.decimals}`);
Response
{
"jsonrpc": "2.0",
"result": {
"context": { "slot": 341200000, "apiVersion": "2.2.4" },
"value": {
"amount": "1000000",
"decimals": 6,
"uiAmount": 1.0,
"uiAmountString": "1"
}
},
"id": 1
}
| Field | Type | Description |
|---|---|---|
amount | string | Raw token amount as a string (no decimal point). |
decimals | u8 | Number of decimal places for the token. |
uiAmount | number or null | Token amount as a float. Deprecated — use uiAmountString. |
uiAmountString | string | Token amount formatted with decimals as a string. |
Common errors
- Not a token account — querying a non-token account (system account, program, etc.) returns an error.
- Account not found — the token account does not exist.
Performance
getTokenAccountBalance is a lightweight call that reads a single token account. Fast and safe to poll for balance updates.
FAQ
What is the difference between amount and uiAmountString?
amount is the raw integer value with no decimal point. uiAmountString divides by 10^decimals. For a USDC account (6 decimals), amount: "1000000" equals uiAmountString: "1" (1 USDC).
Can I use this for Token-2022 accounts?
Yes. getTokenAccountBalance works with both SPL Token and Token-2022 (Token Extensions) accounts.
How do I get the balance for all tokens a wallet holds? Use getTokenAccountsByOwner to find all token accounts owned by a wallet, each with its balance.
Why is uiAmount deprecated?
Floating-point numbers lose precision for large values. uiAmountString is a string representation that preserves exact values regardless of size.
What if the token account is closed? A closed token account no longer exists on-chain. The method returns an error, not a zero balance.
Parameters
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
pubkey | string | Yes | Base-58 encoded public key of the token account. | — |
commitment | string | No | Commitment level: processed, confirmed, or finalized. | finalized |
Updated: