Skip to content

Instantly share code, notes, and snippets.

@0xV4L3NT1N3
Created October 28, 2024 07:06
Show Gist options
  • Select an option

  • Save 0xV4L3NT1N3/553340d1edfc6d23b58695cb6d75e728 to your computer and use it in GitHub Desktop.

Select an option

Save 0xV4L3NT1N3/553340d1edfc6d23b58695cb6d75e728 to your computer and use it in GitHub Desktop.
Get L2 Balances
async function main() {
// query ETH balances on Arbitrum, Base and Optimism
const chains = [42161, 8453, 10]
for (const chain of chains) {
// add your key here
const query = await fetch(`https://api.etherscan.io/v2/api
?chainid=${chain}
&module=account
&action=balance
&address=0xb5d85cbf7cb3ee0d56b3bb207d5fc4b82f43f511
&tag=latest&apikey=YourApiKeyToken`)
const response = await query.json()
const balance = response.result
console.log(balance)
}
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment