Get Supply and Marketcap of a Token
Get Supply of a Token
Let's see how to get the supply of a Token. We are taking TONCOIN token example in the following query. The token address for TONCOIN token is 0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1 You can check out the query here.
query MyQuery {
EVM(network: eth, dataset: combined) {
Transfers(
where: {
Transfer: {
Currency: {
SmartContract: { is: "0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1" }
}
Success: true
}
}
) {
minted: sum(
of: Transfer_Amount
if: {
Transfer: {
Sender: { is: "0x0000000000000000000000000000000000000000" }
}
}
)
burned: sum(
of: Transfer_Amount
if: {
Transfer: {
Receiver: { is: "0x0000000000000000000000000000000000000000" }
}
}
)
}
}
}
Get Marketcap of a token
Below query can be used to calculate Marketcap of a Token, first the query gets supply in the amount
field then query uses join to get the PriceInUSD
. Multiplying both of these will give you marketcap of the token.
In this example, we are calculating marketcap of Pepes Dog (ZEUS) token which has smart contract address 0x0f7dC5D02CC1E1f5Ee47854d534D332A1081cCC8
.
Try the query here.
{
EVM(dataset: combined) {
Transfers(
limit: {count: 1}
where: {Call: {Create: true}, Transfer: {Currency: {SmartContract: {is: "0x0f7dc5d02cc1e1f5ee47854d534d332a1081ccc8"}}, Sender: {is: "0x0000000000000000000000000000000000000000"}}}
) {
Transfer {
Amount
Sender
Receiver
}
joinDEXTradeByTokens(
limit: {count: 1}
join: inner
Trade_Currency_SmartContract: Transfer_Currency_SmartContract
) {
Trade {
Price(maximum: Block_Time)
PriceInUSD
}
}
}
}
}