Token Contract Metrics

node v10.23.3
version: 3.0.0
endpointsharetweet
const Web3Data = require("web3data-js@0.6.1") // Create the Web3Data instances passing in your API Key (Get one! -> amberdata.io/onboarding) 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}` ) })
Loading…

no comments

    sign in to comment