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://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"getBalance","params":["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "getBalance",
  "params": [
    "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
  ],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", 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.