以下為使用 Node.js 套件 Etherscan 串接以太坊區塊鏈 (ERC20)
可查詢指定錢包地址餘額, 近期交易
const Etherscan = require('etherscan');
// API_KEY 官方可申請: https://etherscan.io/apis
const etherscan = new Etherscan('API_KEY');
(async () => {
// 錢包餘額
const data = await etherscan.getEtherBalance({
address: '錢包地址'
});
console.log(data)
// 近期交易
const dataList = await etherscan.getTxList({
address: '錢包地址',
startblock: 0, // Optional
endblock: 0, // Optional
sort: 'desc' // Optional, default 'asc'
});
console.log(dataList)
})();