Token Contract Metrics

node v10.24.1
version: 3.0.0
const Web3Data = require("web3data-js@0.6.1") // Create the Web3Data instances passing in your API Key (Get one! -> const w3d = new Web3Data(process.env.API_KEY) // Need profressional key to work const profKeyError = e => console.log('Need Professional API Key') // Contract we'll use as an example but you would but the address of your dApp here const BAT_CONTRACT = '0x0d8775f648430679a709e98d2b0cb6250d2887ef' // Get the latest token holders const tokenHolders = w3d.token.getHolders(BAT_CONTRACT).catch(profKeyError) // Get historical token transfers + price for analysis const tokenTransfers = w3d.token.getTransfers(BAT_CONTRACT).catch(profKeyError) // Watch for new token transfers w3d.connect() w3d.on({eventName: 'token_transfers', filters: {address: BAT_CONTRACT}}, transfer => { const amount = transfer.amount / Math.pow(10, 18) const time = (new Date(transfer.timestamp)).toLocaleString() console.log(`${amount} BAT transfered at ${time}` ) })

no comments

    sign in to comment