Skip to content

feat(worker): add Etherscan API proxy for free contract verification#330

Merged
AugustoL merged 2 commits intoopenscan-explorer:devfrom
AugustoL:feat/etherscan-worker-proxy
Mar 19, 2026
Merged

feat(worker): add Etherscan API proxy for free contract verification#330
AugustoL merged 2 commits intoopenscan-explorer:devfrom
AugustoL:feat/etherscan-worker-proxy

Conversation

@AugustoL
Copy link
Collaborator

Description

Add an Etherscan V2 API proxy to the existing Cloudflare Worker so that contract verification lookups work for all users out of the box, without requiring them to configure their own API key.

Related Issue

Closes #322

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Performance improvement
  • Other (please describe):

Changes Made

Worker (worker/)

  • New route POST /etherscan/verify — Proxies contract verification requests to Etherscan V2 API using a shared API key stored as a Worker secret
  • Separate rate limiting — 30 requests/minute per IP (independent from AI's 10/min)
  • Request validation — Validates chainId (positive integer) and address (0x + 40 hex chars)
  • ETHERSCAN_API_KEY secret — Set via wrangler secret put ETHERSCAN_API_KEY

Frontend (src/)

  • contractLookup.ts — Etherscan fallback now always runs: uses user key if configured, otherwise proxies through the OpenScan Worker
  • useEtherscan.ts — Same logic: no longer requires apiKey to activate, uses worker proxy as default
  • User-provided keys still work — Direct Etherscan calls bypass the proxy for higher rate limits

Screenshots (if applicable)

N/A — backend change, verification results appear in existing contract UI

Checklist

  • I have run npm run format:fix and npm run lint:fix
  • I have run npm run typecheck with no errors
  • I have tested my changes locally
  • I have updated documentation if needed
  • My code follows the project's architecture patterns

Additional Notes

  • After deploying the worker, run: wrangler secret put ETHERSCAN_API_KEY
  • The Etherscan V2 API key supports 60+ chains with a single key
  • CORS, rate limiting, and payload validation follow the same pattern as the existing Groq AI proxy

Add /etherscan/verify route to the Cloudflare Worker that proxies
contract verification requests to Etherscan V2 API using a shared
API key. Frontend now uses the worker proxy as default fallback when
no user key is configured, making verification free for all users.

Closes openscan-explorer#322
@github-actions
Copy link

github-actions bot commented Mar 19, 2026

🚀 Preview: https://pr-330--openscan.netlify.app
📝 Commit: a27369ee7d9fa51ed2e33976b789dc596f6915fa

Remove hasEtherscanKey gate from useContractVerification so that
Etherscan verification runs for all users via the worker proxy,
not just those with a configured API key.
@AugustoL AugustoL merged commit da00c68 into openscan-explorer:dev Mar 19, 2026
4 of 7 checks passed
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