TriportRPC

getBalance

POSThttps://api.triport.io/v1/sol

Returns the lamport balance of the account of the provided Solana public key.

Solanasol_read_rpcfree+ — 20 / 60 / 200 / 600 RPS (free / basic / pro / business)

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

JSON-RPC params is a positional array: [pubkey, config?].

pubkeystring (base-58)required
The account public key to query. Must match ^[1-9A-HJ-NP-Za-km-z]{32,44}$.
configobjectoptional
Optional configuration object (see below).
commitmentstringoptional
Commitment level: processed, confirmed, or finalized.
minContextSlotintegeroptional
Minimum slot the request must be evaluated at.

Response

The example above queries the Wrapped-SOL mint and returns 10000000000 lamports (10 SOL).

resultobject
RpcResponseU64 envelope.
result.contextobject
The context the response was evaluated against.
result.context.slotinteger
The slot at which the balance was read.
result.context.apiVersionstring
The node software version that served the request.
result.valueinteger
The account balance in lamports.

Errors

Errors are returned in the standard JSON-RPC error envelope. See the shared errors reference for the full envelope shape and shared codes.

CodeMeaningWhen it happens
-32602Invalid paramspubkey is missing, not a valid base-58 string, or config is malformed.
401UnauthorizedMissing or invalid Authorization: Bearer key.
429Rate limitedMore than your tier's RPS for sol_read_rpc (20 / 60 / 200 / 600).

Examples

JavaScript (fetch)

const res = await fetch("https://api.triport.io/v1/sol", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "getBalance",
    params: ["So11111111111111111111111111111111111111112"],
  }),
});


const { result } = await res.json();
console.log(`Balance: ${result.value / 1e9} SOL (slot ${result.context.slot})`);

TypeScript SDK (@triport/sdk)

import { TriportClient } from "@triport/sdk";


const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY });


const { context, value } = await client.solana.getBalance(
  "So11111111111111111111111111111111111111112",
  { commitment: "finalized" }
);


console.log(`Balance: ${value / 1e9} SOL (slot ${context.slot})`);

Python (triport-sdk)

import os
from triport import TriportClient


client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])


result = client.solana.get_balance(
    "So11111111111111111111111111111111111111112",
    commitment="finalized",
)


print(f"Balance: {result['value'] / 1e9} SOL (slot {result['context']['slot']})")

Notes

  • Lamports, not SOL: value is always an integer count of lamports. Divide by 1e9 for a SOL figure.
  • Non-existent accounts: an account that has never been funded returns value: 0.
  • Commitment defaults: when commitment is omitted, the node's default commitment applies. Pass finalized for the strongest consistency guarantee.
  • Related methods: use getMultipleAccounts / getAccountInfo to read full account data alongside the balance, and getSlot to inspect the current slot the cluster has reached.