Learn getBalance use cases, code examples, request parameters, response structure, and tips.
getBalance
RPC method is a straightforward way to find out the native SOL balance of any account on the Solana blockchain. It returns the balance in lamports (1 SOL = 1,000,000,000 lamports).
This method is more lightweight than getAccountInfo
if you only need the SOL balance and no other account details.
publicKey
(string, required): The base-58 encoded public key of the account to query.
config
(object, optional): A configuration object with the following fields:
commitment
(string, optional): Specifies the commitment level to use for the query. Defaults to finalized
.
finalized
: The node will query the most recent block confirmed by the supermajority of the cluster as having reached maximum lockout.confirmed
: The node will query the most recent block that has been voted on by a supermajority of the cluster.processed
: The node will query its most recent block. Note that the block may not be complete.minContextSlot
(number, optional): The minimum slot that the request can be evaluated at.result
field of the JSON-RPC response will be an object containing:
context
(object):
slot
(number): The slot at which the balance was retrieved.apiVersion
(string, optional): The RPC API version (may not be present from all nodes).value
(number): The balance of the account in lamports (unsigned 64-bit integer).getBalance
will typically return a value of 0
lamports.
9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
) on mainnet. This program account itself holds SOL for rent exemption.
Note: Replace YOUR_API_KEY
with your actual Helius API key in the examples below.
getBalance
is more efficient than getAccountInfo
as it fetches less data.getBalance
will return 0
. This can be a quick way to check for account existence if you only care about its SOL balance.LAMPORTS_PER_SOL
(1,000,000,000) to convert it to SOL.commitment
can affect how quickly you get the balance and how confirmed that balance is. For most UI display purposes, confirmed
offers a good balance. For critical financial transactions, finalized
provides the highest assurance. See Solana Commitment Levels for detailed information.getMultipleAccounts
: While getBalance
is for a single account, if you need balances for many accounts, using getMultipleAccounts
and then extracting the lamport balance from each account’s info can be more performant than many individual getBalance
calls.