getTokenSupply

Learn getTokenSupply use cases, code examples, request parameters, response structure, and tips.

The getTokenSupply RPC method in CoinVera retrieves the total supply of a specific SPL token mint. This method is essential for understanding the overall quantity of tokens created and is especially useful for token dashboards, explorers, and tokenomics tracking.


✅ Common Use Cases

  • Displaying Token Information Show the total token supply in wallets, token explorers, or DeFi dashboards.

  • Tokenomics Analysis Understand how many tokens exist and how that relates to market cap or distribution.

  • Supply Verification Validate supply directly from the on-chain mint account for auditing or compliance.

  • Monitoring Supply Changes Detect increases or decreases in supply for mintable tokens (e.g., stablecoins or utility tokens with active minting authority).


🧾 Request Parameters

[
  mintAddress: string,        // Required – Base-58 token mint address
  options?: {
    commitment?: string       // Optional – "processed", "confirmed", or "finalized"
  }
]
  • mintAddress: The public key of the SPL token mint.

  • commitment (optional): The network state to query against. Defaults to the node's standard (typically finalized).


📦 Response Structure

The value field contains detailed supply information:

{
  "context": { "slot": 221446650 },
  "value": {
    "amount": "500000000000",
    "decimals": 6,
    "uiAmount": 500000.0,
    "uiAmountString": "500000"
  }
}
  • amount: Total supply in raw units (not adjusted for decimals).

  • decimals: Number of decimal places defined for this token.

  • uiAmount: Total supply as a float (may be null or imprecise).

  • uiAmountString: Total supply as a string (accurate and display-friendly).


🧪 Example

Query the Supply of a Specific Token Mint

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenSupply",
  "params": [
    "TokenMintAddressHere"
  ]
}

Code Examples

const fetch = require('node-fetch');

async function getTokenSupply(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getTokenSupply',
        "params": [
            "f68ejXhHX8M71pdnutQf8BMthpT4jJuhT7kHkdZpump",
            { "commitment": "confirmed" }
          ]
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getTokenSupply(RPC_URL);

Example Response

{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "apiVersion": "2.2.16",
      "slot": 355409363
    },
    "value": {
      "amount": "999999999203241",
      "decimals": 6,
      "uiAmount": 999999999.203241,
      "uiAmountString": "999999999.203241"
    }
  },
  "id": 1
}

💡 Developer Tips

  • Decimals Matter Always use the decimals field to properly convert amount into a human-readable value.

  • Immutable by Default Most SPL tokens have a fixed supply unless governed by a mint authority. Track getMint to see if further minting is possible.

  • Prefer uiAmountString for Display For accurate and consistent formatting, use uiAmountString instead of uiAmount.

  • Data Source Is Direct This method reads data directly from the mint account—not from token accounts—ensuring reliable totals.

  • Burns Don’t Change Mint Supply Burning typically occurs at the token account level and does not reduce the mint’s recorded total unless explicitly programmed.


The getTokenSupply method is a vital part of working with SPL tokens, enabling reliable supply visibility for audits, analytics, and user interfaces built on CoinVera.

Last updated