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)
const ETH_ADDRESS = '0x0681d8db095565fe8a346fa0277bffde9c0edbbf'
const BTC_ADDRESS = '1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY'
const LTC_ADDRESS = 'Lbuzsisqmp8KyxuotRa8QUz5owr2cVMJGL'
const ZEC_ADDRESS = 't1M5GSbdVpPA1XFkuzi12sJyqGkrEEfGwLJ'
// Specify endDate to get historical data
const endDate = (new Date()).getTime()
// Get the current balances for each address
const [ ethBalance, btcBalance, ltcBalance, zecBalance ] = await Promise.all([
w3d.btc.address.getBalance(BTC_ADDRESS, { includePrice: true }),
w3d.ltc.address.getBalance(LTC_ADDRESS, { includePrice: true }),
w3d.zec.address.getBalance(ZEC_ADDRESS, { includePrice: true })
])
/* Uncomment if using Professional plan to run.
// For ethereum we can get Eth balance and token balances like so:
const balances = await w3d.address.getBalances(ETH_ADDRESS, { includePrice: true })
*/
/* Uncomment if using Professional plan to run.
// Gets the historical balances for each address
const [ ethBalance, btcBalance, ltcBalance, zecBalance ] = await Promise.all([
w3d.address.getBalance(ETH_ADDRESS, { includePrice: true, endDate }).then(data => data.data),
w3d.btc.address.getBalance(BTC_ADDRESS, { includePrice: true, endDate }).then(data => data.data),
w3d.ltc.address.getBalance(LTC_ADDRESS, { includePrice: true, endDate }).then(data => data.data),
w3d.zec.address.getBalance(ZEC_ADDRESS, { includePrice: true, endDate }).then(data => data.data)
])
*/
// This will return an array of the last 100 historical balances for each address
console.log({ethBalance, btcBalance, ltcBalance, zecBalance})