getBalance — Solana RPC Method
getBalance returns the current lamport balance for a single Solana account. It is the simplest way to check how much SOL an address holds.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pubkey | string | Yes | Base-58 encoded public key of the account. |
commitment | string | No | processed, confirmed, or finalized. Default: finalized. |
minContextSlot | number | No | Minimum slot at which the request can be evaluated. |
Request
curl -X POST https://api.mainnet-beta.solana.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBalance",
"params": [
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"
]
}'
TypeScript (@solana/kit)
import { createSolanaRpc, address, lamports } from "@solana/kit";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const { value } = await rpc
.getBalance(address("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"))
.send();
const sol = Number(value) / 1_000_000_000;
console.log(`Balance: ${sol} SOL`);
Response
{
"jsonrpc": "2.0",
"result": {
"context": { "slot": 341197053, "apiVersion": "2.2.4" },
"value": 1000000000
},
"id": 1
}
| Field | Type | Description |
|---|---|---|
value | u64 | Account balance in lamports. 1 SOL = 1,000,000,000 lamports. |
context.slot | u64 | The slot at which the value was read. |
If the account does not exist, value is 0.
Common errors
- Invalid public key — a malformed base-58 string returns a parse error. Verify the key is exactly 32 bytes (43-44 base-58 characters).
- Node behind — if
minContextSlotis set higher than the node’s current slot, the request fails with a slot-not-reached error.
Performance
getBalance is one of the lightest RPC calls. It reads a single u64 from the account index without transferring any account data. Most providers allow high rate limits for this method. If you need both the balance and other account fields (owner, data), use getAccountInfo instead to save a round trip.
FAQ
What is the difference between getBalance and getAccountInfo?
getBalance returns only the lamport balance as a number. getAccountInfo returns the full account structure: balance, owner, data, executable flag, and rent epoch. Use getBalance when you only need the balance.
Does getBalance work for token accounts?
It returns the SOL (lamport) balance of any account, including token accounts. To get the SPL token balance, use getTokenAccountBalance instead.
What happens if the account does not exist?
The response value is 0. There is no error — a nonexistent account simply has zero lamports.
How do I convert lamports to SOL? Divide by 1,000,000,000 (10^9). For example, 2_500_000_000 lamports = 2.5 SOL.
Which commitment level should I use?
Use finalized (the default) for displaying balances to users. Use confirmed when you need faster reads and can tolerate the small chance of a rollback. Use processed only for real-time monitoring where speed matters more than certainty.
Parameters
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
pubkey | string | Yes | Base-58 encoded public key of the account to query. | — |
commitment | string | No | Commitment level: processed, confirmed, or finalized. | finalized |
minContextSlot | number | No | Minimum slot at which the request can be evaluated. | — |
Updated: