'How can I display Total Supply and Circulating Supply for SPL token(Solana based token) on CMC and CG?
I want to write an API endpoint to display TOTAL SUPPLY and Circulating Supply for SPL-token as a numerical value. SPL tokens are fungible tokens on the Solana Blockchain. But I only have an example for ETH. Looking forward to solving this problem.
Solution 1:[1]
You can get the total supply directly through: https://docs.solana.com/developing/clients/jsonrpc-api#gettokensupply
Circulating supply is a bit trickier, and depends on whether or not you freeze tokens. For that, you need to:
- get all of the token accounts for your mint using
getProgramAccountshttps://docs.solana.com/developing/clients/jsonrpc-api#getprogramaccounts, which a nice example at https://solanacookbook.com/references/accounts.html#get-program-accounts - iterate through the parsed program accounts, and subtract any frozen tokens from the total supply
Or you can add any other specific logic needed for your circulating supply.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jon C |
