Created
September 10, 2023 07:02
-
-
Save miguelmota/c8e1ff92b2d3bb2deea8f85c89c89837 to your computer and use it in GitHub Desktop.
JavaScript get etherscan api transactions for account address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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