getTokenSupply
Returns the total supply of an SPL Token type.
Common use cases
| Calculate Token Market Capitalization | Fetch total token supply and multiply by current token price to calculate market cap. Use the uiAmount or uiAmountString field (already decimal-adjusted) rather than manually converting the raw amount field. |
| Display Total Supply in Token Explorers | Show formatted total supply with proper decimal places in token dashboard UIs. Use the decimals field from the response to ensure correct number formatting for user display. |
| Monitor Supply Changes for Security Analysis | Track token supply over time to detect unexpected minting events or rug pull indicators. Poll getTokenSupply periodically and alert if supply increases dramatically without announced token emissions. |
| Format Token Amounts for UI Display | Retrieve the decimals field to properly format raw token amounts throughout your application. This eliminates need for separate mint account queries just to get decimal configuration. |
| Verify Token Mint Validity | Test if a mint address exists and is valid on the current network by calling getTokenSupply. A successful response confirms the mint exists; 'could not find account' error indicates invalid or wrong-network mint address. |
Parameters
pubkey (string, required)
Pubkey of the token Mint to query, as base-58 encoded string
config (object, optional)
Configuration object containing the following fields:
Fields:
commitment(string): The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.
Request
- cURL
- JavaScript
- Python
curl https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenSupply",
"params": [
"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E",
{
"commitment": "finalized"
}
]
}'
// Using fetch
const response = await fetch('https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenSupply",
"params": [
"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E",
{
"commitment": "finalized"
}
]
})
});
const data = await response.json();
console.log(data);
import requests
import json
url = 'https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
data = {
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenSupply",
"params": [
"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E",
{
"commitment": "finalized"
}
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Replace mainnet with devnet in the URL to query devnet instead.
Response
{
"jsonrpc": "2.0",
"result": {
"context": { "slot": 1114 },
"value": {
"amount": "100000",
"decimals": 2,
"uiAmount": 1000,
"uiAmountString": "1000"
}
},
"id": 1
}
Response Fields
amount (string)
The raw total token supply without decimals, a string representation of u64
decimals (u8)
Number of base 10 digits to the right of the decimal place
uiAmount (number | null)
The total token supply, using mint-prescribed decimals
uiAmountString (string)
The total token supply as a string, using mint-prescribed decimals
FAQ and Troubleshooting
Does getTokenSupply return circulating supply or total supply?
It returns total supply. Circulating supply requires custom calculation by subtracting burned tokens and locked/team allocations from the total. There is no built-in RPC method for circulating supply.
Why do I get 'Invalid param: could not find account' error?
The mint address doesn't exist on your RPC network. Verify you're querying mainnet-beta for mainnet tokens (not devnet), and ensure the mint address is correct. This is the most common getTokenSupply error.
What's the difference between amount and uiAmount fields?
amount is the raw token supply as a string without decimal adjustment. uiAmount and uiAmountString are decimal-adjusted values (amount ÷ 10^decimals) ready for display. Always use uiAmountString to avoid JavaScript precision loss.
How do I calculate market cap using getTokenSupply?
Call getTokenSupply to get value.uiAmount (total supply), fetch current token price from a price API (like CoinGecko), then calculate: marketCap = price × supply.value.uiAmount. Ensure both values use same currency (USD, etc).
Which commitment level should I use for supply queries?
Use "finalized" (default) for most use cases like market cap or dashboards. Supply rarely changes, so real-time updates aren't critical. Only use "confirmed" if monitoring for immediate mint events and can tolerate potential rollbacks.
Related Methods
getTokenAccountBalance
Returns balance of a specific token account (holder balance), whereas getTokenSupply returns total supply across all accounts. Use together to calculate holder's percentage of total supply.
getTokenLargestAccounts
Returns top holder accounts by balance for a token mint. Useful alongside getTokenSupply to analyze token distribution and identify whale wallets or team allocations.
getAccountInfo
Lower-level method to fetch raw mint account data. Use getTokenSupply instead for supply queries as it returns parsed, decimal-adjusted values without manual deserialization.
External Resources
- Solana Official Documentation
- SPL Token Program Documentation - Comprehensive guide to SPL Token Program covering mint accounts, supply mechanics, and token economics. Essential context for understanding what getTokenSupply returns and how minting affects supply.