Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Transactions + Token Transfers

node v10.24.1
version: 2.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) // Token transfers by token address const BAT_CONTRACT = '0x0d8775f648430679a709e98d2b0cb6250d2887ef' // Get historical token transfers of the BAT contract const batTokenTransfers = w3d.token.getTransfers(BAT_CONTRACT) // Init websocket connection w3d.connect() // Watch for all BAT transfer events and log the transfer details w3d.on({eventName:'token_transfers', filters: {BAT_CONTRACT} }, transfer => { console.log(`${transfer.amount} DAI transfered at ${transfer.timestamp}`) }) /* - - - - - - - - - - */ // Token transfers by account - Get metrics on specific account token transfers const address = '0x3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be' // šŸ‹ // Get historical token transfers of an account const tokenTransfers = w3d.address.getTokenTransfers(address) // Watch for all token transfer events by address w3d.on({eventName:'address:token_transfers', filters: {address} }, transfer => { console.log(`${transfer.tokenAddress.slice(0,10)} transfered at ${transfer.timestamp}`) })
Loadingā€¦

no comments

    sign in to comment