TriportRPC

getTokenAccountBalance

Last updated:

getTokenAccountBalance returns the balance held by one SPL Token account: the raw integer amount, the token's decimals, and the human-readable uiAmount / uiAmountString already scaled by those decimals.

The pubkey you pass must be the address of a token account — not the wallet that owns it, and not the token mint. A token account is the per-mint holding account derived for an owner (commonly the associated token account). Passing a wallet or a mint address yields an invalid-params error rather than a balance. To go from a wallet to its token accounts, resolve them first with getTokenAccountsByOwner, then call this method on the resulting account addresses.

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 the node has reached at least a given slot before serving the request.

Parameters

getTokenAccountBalance parameters
NameTypeRequiredDescription
pubkeyPubkeyYes
configCommitmentConfigNo

Returns

getTokenAccountBalance 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":"getTokenAccountBalance","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": "getTokenAccountBalance",
  "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":"getTokenAccountBalance","params":["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"],"jsonrpc":"2.0"},
)
print(resp.json())

Usage

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

FAQ

What does getTokenAccountBalance do?
Returns the token balance of a single SPL Token account.
How many credits does getTokenAccountBalance cost?
getTokenAccountBalance costs 1 credit(s) per call on Triport by default.
Is getTokenAccountBalance available over WebSocket?
getTokenAccountBalance is an HTTP JSON-RPC method.