Created
August 9, 2021 16:20
-
-
Save OrderAndCh4oS/1ce21f011bd60016ca86ca1006d2e8de to your computer and use it in GitHub Desktop.
get-burns.js
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
import fetch from 'node-fetch'; | |
import ObjectsToCsv from 'objects-to-csv'; | |
import path from 'path'; | |
const getBurns = async(objktId) => { | |
const response = await fetch( | |
`https://api.tzkt.io/v1/operations/transactions?target=KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton&entrypoint=transfer&status=applied&limit=10000¶meter.[0].txs.[0].token_id=${objktId}¶meter.[0].txs.[0].to_=tz1burnburnburnburnburnburnburjAYjjX&select=id,hash,parameter`); | |
const data = await response.json(); | |
let i = 1; | |
return data.reduce((arr, d) => { | |
for(const row of d.parameter.value) { | |
for(const burn of row.txs) { | |
if(Number(burn.token_id) === objktId) { | |
for(let j = 0; j < burn.amount; j++) { | |
arr.push({seed: `${d.hash}${j > 0 ? `_${1 + j}` : ''}`, walletId: row.from_, edition: i}); | |
i++; | |
} | |
} | |
} | |
} | |
return arr; | |
}, []); | |
}; | |
const burns = await getBurns(103271); // Replace with the burn objkt id | |
await new ObjectsToCsv(burns).toDisk(path.join('csv', `burns.csv`)); | |
console.log(burns.slice(-30)); | |
console.log('BURNS:', burns.length); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment