Skip to content

Add native ETH balance query support via Etherscan API v2#53

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-balance-api-endpoint
Draft

Add native ETH balance query support via Etherscan API v2#53
Copilot wants to merge 3 commits intomainfrom
copilot/add-balance-api-endpoint

Conversation

Copy link

Copilot AI commented Feb 12, 2026

Implements native ETH balance queries using Etherscan's balance endpoint. Repository previously only supported ERC-20 token balance queries via addresstokenbalance.

Changes

  • Scripts: query-balance.{js,py,sh} for querying ETH balance with parameters: chainid, module, address, tag
  • Documentation: ETHERSCAN_BALANCE.md covering API usage, response format, and wei-to-ETH conversion
  • README: Updated with balance query examples and script references

Technical Details

  • Reuses existing validation/config infrastructure (etherscan-common.{js,py})
  • Python uses Decimal for precise wei-to-ETH conversion
  • Bash includes 30s timeout on curl to prevent hanging
  • JavaScript includes precision warning for large balances
# Query ETH balance
./query-balance.sh --apikey YOUR_KEY --address 0x123... --tag latest

# Response includes both wei and ETH:
Balance (wei): 1234567890123456789
Balance (ETH): 1.234567890123456789 ETH

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.etherscan.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node query-balance.js --apikey TEST_KEY (dns block)
    • Triggering command: /usr/bin/python3 python3 ./query-balance.py --apikey TEST_KEY (dns block)
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)
  • docs.etherscan.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
const { apikey, address, chainid, tag } = options;

if (!apikey) {
console.error(messages.errors.apiKeyRequired + '. Use --apikey option or set ETHERSCAN_API_KEY environment variable.');

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This logs sensitive data returned by
an access to apiKeyRequired
as clear text.

Copilot Autofix

AI 5 days ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
Copilot AI changed the title [WIP] Add balance API endpoint parameters Add native ETH balance query support via Etherscan API v2 Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants