Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

Etherproxy

A caching JSON-RPC proxy for Ethereum nodes. Sits in front of a node, deduplicates and caches identical requests for a configurable TTL, and forwards uncached ones upstream.

How it works

  • Accepts HTTP POST JSON-RPC requests
  • Normalizes request IDs and uses method + params as the cache key (id is excluded)
  • Serves cached responses without hitting the upstream node until TTL expires
  • Sends a Telegram alert on errors (throttled to once per 30 seconds)

Install & build

pnpm install
pnpm build

Usage

node dist/index.js \
--hostname 0.0.0.0 \
--port 8545 \
--target http://localhost:8546 \
--ttl 60 \
--timeout 30

Required arguments

ArgumentDescription
--hostnameInterface to bind
--portPort to listen on
--targetUpstream JSON-RPC URL
--ttlCache TTL in seconds
--timeoutUpstream request timeout in seconds

Optional arguments

ArgumentEnv varDescription
--max-body-sizeMAX_BODY_SIZEMax request body in bytes (default 1 MB)
--telegram-tokenTELEGRAM_TOKENBot token for error alerts
--telegram-chat-idTELEGRAM_CHAT_IDChat ID for error alerts
--telegram-nameTELEGRAM_NAMELabel prepended to alerts (e.g. node hostname)
--verboseLog every request and response
--recordWrite timestamped log file to disk
--metricsWrite etherproxy-metrics-<timestamp>.json every 15 minutes
--management-portStart a management server on 127.0.0.1:<port> (see below)

Management API

When --management-port is set, a second HTTP server binds exclusively to 127.0.0.1 on that port and exposes a single endpoint for live reconfiguration:

PUT /target

Change the upstream JSON-RPC URL without restarting.

curl -X PUT http://127.0.0.1:9000/target -d 'http://backup-node:8546'

The response body confirms the new target. The change takes effect immediately for all subsequent cache misses.

Structure

FileRole
src/proxy.tsCore proxy logic — createProxy(config) returns an HTTP server
src/index.tsCLI entry point — parses args, sets up logging, calls createProxy

About

Caching JSON-RPC proxy for Ethereum nodes with request deduplication, TTL-based caching, and live upstream reconfiguration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages