Returns the token balance of an SPL Token account.
Supported on Solana (mainnet) only.
Parameters
<string>
- Pubkey of Token account to query, as base-58 encoded string- (optional)
<object>
- Configuration object containing the following field:- (optional)
commitment: <string>
- Commitment
- (optional)
Returns
The result will be an RpcResponse JSON object with value
equal to a JSON object containing:
amount: <string>
- the raw balance without decimals, a string representation of u64decimals: <u8>
- number of base 10 digits to the right of the decimal placeuiAmount: <number|null>
- the balance, using mint-prescribed decimals DEPRECATEDuiAmountString: <string>
- the balance as a string, using mint-prescribed decimals
For more details on returned data: The Token Balances Structure response from getBlock follows a similar structure.
API Endpoint
The format of an Solana API endpoint is
https://open-platform.nodereal.io/{{apiKey}}/solana/
Here is an example:
https://open-platform.nodereal.io/4c0a1c23661a4e26bcbcwed461e34ea9/solana/
Example
Request
curl https://open-platform.nodereal.io/{{apiKey}}/solana/ \
-X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0", "id":1, "method":"getTokenAccountBalance", "params": ["7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7"]}'
Result
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 1114
},
"value": {
"amount": "9864",
"decimals": 2,
"uiAmount": 98.64,
"uiAmountString": "98.64"
},
"id": 1
}
}