JavaScript get etherscan api transactions for account address



getEtherscanTxs.ts


async function getEtherscanTxs(chain: string, accountAddress: string) {
const baseUrl = 'https://api-goerli.etherscan.io'
const url = `${baseUrl}/api?module=account&action=txlist&address=${accountAddress}&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken`
const res = await fetch(url)
const json = await res.json()
const txs = json.result
const txHashes = txs.map((tx: any) => tx.hash)
return txHashes
}



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *