getTokenSupply – Solana
The getTokenSupply JSON-RPC method retrieves the total supply of a specific SPL Token type.
The getTokenSupply RPC Solana method returns the total supply of an SPL Token for a given token Mint address.
The response includes both the raw token supply and the formatted supply using mint-prescribed decimals. This method helps developers monitor token metrics via Solana’s Core API.
Supported Networks
This method is available on the following API endpoints:
Mainnet
Devnet
Parameters
Required Parameters
string
(required): The Pubkey of the token Mint to query, provided as a base-58 encoded string.
Optional Parameters
object
(optional): A configuration object containing:commitment (
string
): Defines the level of finality for the request.
Result
The response returns an RpcResponse object containing:
context
(object
): Provides contextual information about the slot.slot
(u64
): The slot number when the token supply was retrieved.
value
(object
):amount
(string
): The raw total supply (without decimals) as a string.decimals
(u8
): The number of decimal places for the token.uiAmount
(number
|null
): The formatted token supply with decimals applied (Deprecated).uiAmountString
(string
): The formatted token supply as a string.
Request Example
API Endpoints
cURL Example
Response
A successful request returns the total token supply.
Example Response
In this response:
amount
: The raw supply as a string.decimals
: The number of decimal places.uiAmountString
: The formatted supply as a string.
Error Handling
Common getTokenSupply error scenarios:
Invalid Mint Pubkey: If the provided Pubkey is invalid.
Network issues: Connectivity problems with the Solana JSON-RPC API endpoints.
Invalid request parameters: Incorrect parameter structure or data types.
Example Error Response
Use Cases
The Solana getTokenSupply method is useful for:
Token analytics: Tracking token supply changes;
DeFi applications: Monitoring liquidity pool supply;
Web3 analytics tools: Displaying token metrics to users;
Wallet applications: Providing token supply information for users.
Code getTokenSupply Example – Web3 Integration
Integration with Web3
By integrating Web3 getTokenSupply into Solana’s Core API, developers can efficiently track token supply, analyze token metrics, and provide real-time token data for Web3 applications. This JSON-RPC method is crucial for applications that require accurate supply information for tokens on the Solana network.
Last updated