Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.soo.network/llms.txt

Use this file to discover all available pages before exploring further.

getTokenAccountBalance RPC Method

Returns the token balance of an SPL Token account.

Parameters

string required
Pubkey of Token account to query
  • Base-58 encoded string
object optional
Configuration object containing the following fields:
commitment string optional
The level of commitment desired when querying state

Code Sample

curl https://rpc.testnet.soo.network/rpc \
-X POST \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenAccountBalance",
  "params": [
    "5ThJTCxpdn54bk3gBAWKZS4K9ogHEX56WooYbXQDnm3Q",
    {
      "commitment": "finalized"
    }
  ]
}'

Response

{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 369624
    },
    "value": {
      "amount": "1000000",
      "decimals": 6,
      "uiAmount": 1.0,
      "uiAmountString": "1.0"
    }
  },
  "id": 1
}

Result Details

The result is an RpcResponse JSON object with value containing:
  • amount: <string>
    • Raw token balance without decimals
    • String representation of u64 integer
    • Represents the full token amount without decimal adjustment
  • decimals: <u8>
    • Number of decimal places for the token
    • Determines how the raw amount should be displayed
  • uiAmount: <number|null> DEPRECATED
    • Balance using mint-prescribed decimals
    • Will be deprecated in future versions
  • uiAmountString: <string>
    • Balance as a string
    • Formatted using mint-prescribed decimal places

Important Notes

  • Similar token balance structure as found in getBlock method
  • Provides both raw and user-friendly token balance representations
  • Decimals help in correct token amount interpretation