Created
August 31, 2021 01:26
-
-
Save togosh/4c7b1d89549ff26ae9778c120a3bfbb2 to your computer and use it in GitHub Desktop.
Total Holders (Past and Present) of HEX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://codeakk.medium.com/hex-development-data-a1b1822446fa | |
// https://togosh.medium.com/hex-developer-guide-3b018a943a55 | |
test(); | |
async function test(){ | |
var numberOfHolders = await get_numberOfHolders(); | |
console.log("Total Holders: " + Number(numberOfHolders).toLocaleString(undefined, {minimumFractionDigits:0, maximumFractionDigits:0})); | |
} | |
async function get_numberOfHolders(){ | |
return await fetch('https://api.thegraph.com/subgraphs/name/codeakk/hex', { | |
method: 'POST', | |
headers: { 'Content-Type': 'application/json' }, | |
body: JSON.stringify({ query: ` | |
query { | |
tokenHolders( | |
first: 1, | |
orderDirection: desc, | |
orderBy: numeralIndex | |
) { | |
numeralIndex | |
} | |
}` | |
}), | |
}) | |
.then(res => res.json()) | |
.then(res => { | |
var numberOfHolders = parseInt(res.data.tokenHolders[0].numeralIndex); | |
return numberOfHolders; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment