Skip to content

Instantly share code, notes, and snippets.

@togosh
Created August 16, 2021 04:24
Show Gist options
  • Save togosh/4f5efb8833021b5e25cbd87f4c7216f0 to your computer and use it in GitHub Desktop.
Save togosh/4f5efb8833021b5e25cbd87f4c7216f0 to your computer and use it in GitHub Desktop.
Tshare Rate of HEX
// https://codeakk.medium.com/hex-development-data-a1b1822446fa
// https://togosh.medium.com/hex-developer-guide-3b018a943a55
test();
async function test(){
var tShareRateHEX = await get_shareRateChange();
console.log("Tshare Rate (HEX): " + tShareRateHEX);
}
async function get_shareRateChange(){
return await fetch('https://api.thegraph.com/subgraphs/name/codeakk/hex', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: `
query {
shareRateChanges(
first: 1,
orderDirection: desc,
orderBy: timestamp
) {
shareRate
tShareRateHearts
tShareRateHex
}
}`
}),
})
.then(res => res.json())
.then(res => {
var tShareRateHEX = res.data.shareRateChanges[0].tShareRateHex;
return tShareRateHEX;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment