Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created September 10, 2023 07:02
Show Gist options
  • Save miguelmota/c8e1ff92b2d3bb2deea8f85c89c89837 to your computer and use it in GitHub Desktop.
Save miguelmota/c8e1ff92b2d3bb2deea8f85c89c89837 to your computer and use it in GitHub Desktop.
JavaScript get etherscan api transactions for account address
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment