Skip to main content

Parameters

string
required
Public key of the token account (base-58 encoded)
object
Configuration object containing:
string
Commitment level (processed, confirmed, finalized)

Response

object
Object containing:
object
number
The slot the request was processed at
object
string
Raw amount of tokens as a string
number
Number of decimals configured for token’s mint
number
Token amount as a float, accounting for decimals
string
Token amount as a string, accounting for decimals

Code Examples

Basic Request

Using web3.js

Notes

  1. Returns the token balance of a token account
  2. The balance is returned in both raw and UI-friendly formats
  3. The response is immediate as it reads from the current state
  4. The balance can change with token transfers and other operations
  5. The account must be a valid token account

Best Practices

  1. Use appropriate commitment level based on your needs
  2. Cache results when appropriate to reduce RPC load
  3. Monitor for changes in token balances
  4. Consider using websocket subscription for real-time updates
  5. Handle network errors and retry when appropriate

Common Errors

Use Cases

  1. Token Balance Analysis
  2. Token Balance Monitoring
  3. Token Balance Planning