getTokenSupply RPC method returns the total supply of a specific SPL Token mint. This is essential for understanding the overall quantity of a token that has been created.
Common Use Cases
- Displaying Token Information: Showing the total supply of a token on an explorer or in a wallet interface.
- Tokenomics Analysis: Understanding the maximum or current total issuance of a token.
- Verification: Checking the supply of a token as reported by the mint account itself.
- Monitoring Supply Changes: If a token is mintable, this can be used to track changes in its total supply over time (though for fungible tokens, the supply is usually fixed or managed by a minting authority).
Request Parameters
-
mintAddress(string, required): The base-58 encoded public key of the token mint whose total supply you want to query. -
options(object, optional): An optional configuration object that can include:commitment(string, optional): Specifies the commitment level for the query (e.g.,"finalized","confirmed","processed").
Response Structure
Theresult.value field in the JSON-RPC response is an object containing details about the token’s supply:
amount(string): The total supply of the token in its smallest denomination (raw amount), as a string. This value is not adjusted for decimals.decimals(u8): The number of decimal places defined for this token mint. This is crucial for converting the rawamountto a human-readable format.uiAmount(number | null): The total supply of the token as a floating-point number, adjusted for the token’sdecimals. This field might be null or less precise;uiAmountStringis generally preferred for display.uiAmountString(string): The total supply of the token as a string, adjusted for the token’sdecimals. This is the most user-friendly representation of the total supply.
Code Examples
Developer Tips
- Immutable Supply (Usually): For most SPL tokens, once minted, the total supply from the perspective of the mint account itself is fixed unless the mint has a specific minting authority that can create more tokens (or burn them, though burning typically happens from token accounts, not the mint’s supply directly).
decimalsis Key: Always use thedecimalsfield to correctly interpret theamountoruiAmountString.- Data Source: This method queries the mint account directly for its supply information.
getTokenSupply RPC method effectively for querying SPL token supply on Solana.