const MIRROR_URL = "https://mainnet.mirrornode.hedera.com"; const FIRST_DINO_BLOCK = 72961723; const LAST_DINO_BLOCK = 72961776; const DINO_TOKEN_ID = '0.0.7907968'; let total_tokens_sold = BigInt(0); let total_associations = 0; let total_buys = 0; let bought_amounts = []; for (let block_id = FIRST_DINO_BLOCK; block_id <= LAST_DINO_BLOCK; block_id ++) { const block_response = await fetch(`${MIRROR_URL}/api/v1/blocks/${block_id}`); const jblock = await block_response.json(); const jblock_from = jblock.timestamp.from; const jblock_to = jblock.timestamp.to; console.log(`${block_id}: tx count: ${jblock.count}, gas used ${jblock.gas_used}`); const transactions_response = await fetch(`${MIRROR_URL}/api/v1/transactions?timestamp=gte:${jblock_from}×tamp=lte:${jblock_to}&limit=200&`); const { transactions } = await transactions_response.json(); for await (const tx of transactions) { if (tx.name == "TOKENASSOCIATE") { let account_tokens_url = `${MIRROR_URL}/api/v1/accounts/${tx.entity_id}/tokens?limit=100`; let dino_token_association_found = false; do { const tokens_response = await fetch(account_tokens_url); const jtokens = await tokens_response.json(); dino_token_association_found = jtokens.tokens.findIndex(tk => tk.token_id == DINO_TOKEN_ID) != -1; if (jtokens.links.next == null) { break; } else { account_tokens_url = `${MIRROR_URL}${jtokens.links.next}`; } } while (!dino_token_association_found); if (dino_token_association_found) { total_associations ++; console.log(` - ${tx.entity_id} associated DINO token`); } } else if (tx.name == "CRYPTOTRANSFER" && tx.token_transfers.findIndex(txt => txt.token_id == DINO_TOKEN_ID) != -1) { const { account, amount } = tx.token_transfers.find(txt => txt.amount > 0); total_tokens_sold += BigInt(amount); total_buys ++; bought_amounts.push(amount); console.log(` - ${account} bought ${amount} DINO`); } } } console.log(`Bought amounts: ${bought_amounts.join(", ")}`); console.log(`Total DINO tokens sold: ${total_tokens_sold}`); console.log(`Total buys: ${total_buys}`); console.log(`Total associations: ${total_associations}`);