A simple RPC proxy server that transparently forwards JSON-RPC requests to an Ethereum RPC provider while handling block range limitations for filter calls.
- Proxies JSON-RPC requests from
http://localhost:PORTtohttps://some.rpc.provider.com - Automatically batches filter calls (like
eth_getLogs) that exceed a maximum block range (default: 10000 blocks) - Supports both single RPC calls and batch requests
- Clone this repository
- Install dependencies:
npm install - Configure the
.envfile:RPC_PROVIDER_URL=https://your.rpc.provider.com RPC_PORT=8545 RPC_HOST=localhost MAX_BLOCK_RANGE=10000
Start the proxy server:
npm start
The proxy will start on the configured port (default: 8545).
Send your RPC requests to http://localhost:8545 the same way you would to your provider:
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock":"0x0","toBlock":"0x100000"}],"id":1}' http://localhost:8545
For batch requests, send an array of RPC calls to the /batch endpoint:
curl -X POST -H "Content-Type: application/json" --data '[{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock":"0x0","toBlock":"0x100000"}],"id":1}, {"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":2}]' http://localhost:8545/batch
When a filter call exceeds the configured maximum block range:
- The proxy splits the request into smaller chunks (e.g., 50,000 blocks each)
- Executes each chunk separately
- Combines the results
- Returns the combined result to the client
All other RPC calls are passed through directly to the provider.