getBalance

The getBalance method returns the lamport balance of a specified account on the Solana blockchain. This is one of the simplest yet most essential RPC methods for any Solana application, providing a quick way to check the native SOL balance of any account without retrieving the complete account information.

Balances on Solana are denominated in lamports, where 1 SOL equals 1,000,000,000 lamports. This smallest unit of SOL is named after Leslie Lamport, the computer scientist famous for his work on distributed systems. Unlike Ethereum's wei conversion, Solana's lamport conversion is straightforward with exactly 9 decimal places. This method is particularly useful for wallet applications, payment processors, and any dApp that needs to verify account balances before executing transactions.

The method supports different commitment levels, allowing developers to choose between speed and finality. You can query the balance at the most recent processed slot for immediate feedback, or wait for confirmed or finalized status for higher security guarantees. This flexibility makes getBalance suitable for both real-time UI updates and critical financial operations.


Parameters

parameter
type
description
accountPubkey
string
Base-58 encoded public key of the account to query
config
object
Optional configuration object
config.commitment
string
Level of commitment: 'processed', 'confirmed', or 'finalized' (default: 'finalized')
config.minContextSlot
number
Optional. Minimum slot that the request can be evaluated at
Return Object
field
type
description
context
object
RPC response context with slot information
context.slot
number
The slot at which this balance was retrieved
value
number
Balance in lamports (1 SOL = 1,000,000,000 lamports)
Request Example
Request
Response Example
Response

Tip: To convert lamports to SOL, divide by 1,000,000,000. For example, 5,000,000,000 lamports = 5 SOL. Use getBalance for checking native SOL balances, and getTokenAccountBalance for SPL token balances.


Share on
Share on FacebookShare on XShare on LinkedIn
Did you find this page useful?