Solana
Solana
Solana
Free tier covers personal projects. Pay-as-you-go scales without a card.
On Solana — the Proof-of-History chain whose native token is SOL — getTokenAccountBalance reads the balance held in one specific SPL token (or Token-2022) account. Unlike getBalance, which reports lamports of SOL, this method targets the data account a program owns for a given token holder. Send a JSON-RPC 2.0 request with positional params to https://solana.therpc.io/YOUR_API_KEY and you get back the token balance of that single account: the raw amount, the mint's decimals, and a ready-to-display uiAmountString.
confirmed or finalized commitment.uiAmountString, which already applies the mint's decimals.| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | pubkey | string | Yes | Base-58 SPL token account address. |
| 2 | config | object | No | Options: commitment. |
| Type | Description |
|---|---|
| object | RpcResponse wrapping { amount, decimals, uiAmount, uiAmountString }. |
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | A param is missing, of the wrong type, or malformed (e.g. a non-base58 pubkey or a bad config field). |
-32603 | Internal error | The node hit an internal error serving the request — retry, and reduce the requested range/encoding if it persists. |
getTokenAccountsByOwner.uiAmountString rather than the uiAmount float; the float can lose precision on large balances, while the string preserves the exact value scaled by decimals.