Ask or search…
K
Links

getTokenSupply

How to Use It

1
// yarn add @tatumio/tatum
2
3
import { TatumSDK, Solana, Network } from '@tatumio/tatum'
4
5
const tatum = await TatumSDK.init<Solana>({ network: Network.SOLANA })
6
7
const tokenMintPubkey = "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"
8
9
const res = await tatum.rpc.getTokenSupply(tokenMintPubkey, config)
10
11
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

The getTokenSupply method returns the total supply of a specific SPL (Solana Program Library) Token in the network.
This method is especially useful for token issuers or traders who want to keep track of the total token supply for market analysis or supply management.
Another use case for this method is for financial services applications or DeFi protocols, where it is important to know the total supply of a token to calculate various financial metrics such as market capitalisation or liquidity.

Parameters

This method takes the following parameters:
  • pubkey (string, required): A string that represents the Pubkey of the token Mint to query.
  • options (object, optional): This object can contain the following fields:
    • commitment (string, optional): Specifies the level of commitment to apply when fetching data.
      • Values: finalized confirmed processed

Return Object

The result will be an RpcResponse JSON object with value equal to a JSON object containing:
  • amount: The raw total token supply without decimals, a string representation of u64.
  • decimals: The number of base 10 digits to the right of the decimal place.
  • uiAmount: The total token supply, using mint-prescribed decimals. Note: This field is deprecated.
  • uiAmountString: The total token supply as a string, using mint-prescribed decimals.

JSON-RPC Request Example

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

JSON-RPC Response Example

{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 1114
},
"value": {
"amount": "100000",
"decimals": 2,
"uiAmount": 1000,
"uiAmountString": "1000"
}
},
"id": 1
}
© Tatum Technology, LLC