A minimum, cached, read-only proxy for Ethereum JSON-RPC requests, optimized for frontend.
bun i
bun devCreate an API token at https://dash.cloudflare.com/profile/api-tokens with the "Edit Cloudflare Workers" template.
cp .secrets.example .secrets # Add your RPC URLs
CLOUDFLARE_API_TOKEN=******** bun secrets # Upload to CloudflareCLOUDFLARE_API_TOKEN=******** bun deployDestroy personal tokens after use.
Pushes to main auto-deploy via GitHub Actions.
Setup:
-
Create a long-lived API token at https://dash.cloudflare.com/profile/api-tokens
- Use "Edit Cloudflare Workers" template
- Scope to your specific account
- No expiration (or 1 year)
- Name it clearly, e.g.
GitHub Actions - rpc-read-proxy
-
Add the token to GitHub repo secrets:
- Settings → Secrets and variables → Actions → New repository secret
- Name:
CLOUDFLARE_API_TOKEN - Value: your token
| Variable | Description | Default |
|---|---|---|
RPC_URI_FOR_[chainId] |
Upstream RPC URL for chain (secret) | - |
LATEST_TTL |
Cache TTL for latest block queries (seconds) |
3 |
HISTORICAL_TTL |
Cache TTL for numeric block queries (seconds) | 3600 |
TTLs are configured in wrangler.toml. RPC URLs are stored as secrets on Cloudflare.
POST /chain/[chainId]
Uses Cloudflare's Cache API to cache POST responses at the edge:
- Queries with
latest,pending, or absent block parameters are cached forLATEST_TTLseconds (default: 3) - Queries with numeric block parameters are cached for
HISTORICAL_TTLseconds (default: 3600) - Batch requests cache each item individually for maximum cache efficiency
Cache keys are generated from the chain ID, method name, and a SHA-256 hash of canonicalized parameters.
Configure rate limiting via Cloudflare's WAF in the dashboard at the domain level:
Setup: Domains → the proxy's public domain → Security → Security rules