Ask or search…
⌃K
Links

getBalance

How to use it

1
// yarn add @tatumio/tatum
2
​
3
import { TatumSDK, Solana, Network } from '@tatumio/tatum'
4
​
5
const tatum = await TatumSDK.init<Solana>({ network: Network.SOLANA })
6
​
7
const res = await tatum.rpc.getBalance('8Ew6iQXcTRHAUNNu3X9VBn1g1bJkXEZJ9gFD2AGKtdPB')
8
​
9
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

The getBalance RPC method is used to retrieve the current balance of a specified account on the Solana blockchain. It's a straightforward and efficient way to monitor and keep track of account balances.
This method is typically used in scenarios where you need to check the available balance before initiating a transaction or for accounting purposes in a wallet application.

Parameters

The getBalance method requires one parameter:
  • (string, required) Pubkey of account to query, as base-58 encoded string
    • Example: "8Ew6iQXcTRHAUNNu3X9VBn1g1bJkXEZJ9gFD2AGKtdPB"

Return object

The getBalance method returns an object containing the following fields:
  • context: An object containing details about the context in which the balance was fetched.
    • slot: The slot at which the data was fetched.
  • value: The current balance of the account, in lamports.

JSON-RPC Request Example

{
"jsonrpc": "2.0",
"id": 1,
"method": "getBalance",
"params": [
"8Ew6iQXcTRHAUNNu3X9VBn1g1bJkXEZJ9gFD2AGKtdPB",
]
}

JSON-RPC Response Example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"context": {
"slot": 194573649
},
"value": 2484257209
}
}
© Tatum Technology, LLC