TriportRPC

getBalance

Last updated:

getBalance returns the balance, in lamports, of the account identified by a base-58 public key. One lamport is 0.000000001 SOL (1 SOL = 1,000,000,000 lamports), so divide the returned value by 1e9 to display a SOL amount.

The balance is reported relative to a particular slot, returned in the context object. Use the optional commitment config to control how finalized that slot must be, and minContextSlot to require that the node has reached at least a given slot before serving the request.

This is the canonical way to read a wallet or program-owned account's native SOL balance. To read SPL token balances instead, use the token-account methods rather than getBalance.

Parameters

getBalance parameters
NameTypeRequiredDescription
pubkeyPubkeyYes
configCommitmentConfigNo

Returns

getBalance return value
FieldType
resultobject

Examples

curl https://triport.io/sol \
  -X POST -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <api-key>' \
  -d '{"id":1,"method":"getBalance","params":["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"],"jsonrpc":"2.0"}'
const res = await fetch("https://triport.io/sol", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
  body: JSON.stringify({
  "id": 1,
  "method": "getBalance",
  "params": [
    "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
  ],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post(
    "https://triport.io/sol",
    headers={"Authorization": "Bearer <api-key>"},
    json={"id":1,"method":"getBalance","params":["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"],"jsonrpc":"2.0"},
)
print(resp.json())
{
  "id": 1,
  "result": {
    "value": 508423428349,
    "context": {
      "slot": 427699290,
      "apiVersion": "4.0.2"
    }
  },
  "jsonrpc": "2.0"
}

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet, devnet, testnet.
  3. Credit cost: 1 per call.

FAQ

What does getBalance do?
Returns the lamport balance of the account of the provided Solana public key.
How many credits does getBalance cost?
getBalance costs 1 credit(s) per call on Triport by default.
Is getBalance available over WebSocket?
getBalance is an HTTP JSON-RPC method.