A high-performance JSON-RPC 2.0 proxy for Sei blockchain nodes with WebSocket pooling, automatic HTTP fallback, and response caching.
- Dual transport support — Routes requests via WebSocket or HTTP based on method compatibility
- WebSocket connection pooling — Maintains a pool of persistent connections for low-latency requests
- Automatic fallback — Falls back to HTTP when WebSocket calls fail or return incompatible errors
- Response caching — Memcached integration for cacheable RPC methods
- Batch requests — Handles JSON-RPC batch requests with configurable concurrency limits
- Method filtering — Allowlist/blocklist support for controlling exposed RPC methods
- Metrics & health checks — Prometheus metrics endpoint and health status reporting
- TLS support — Optional HTTPS/WSS termination
waterway, err := NewWaterway(ctx,
WithListenAddr(":8545"),
WithSeiWSEndpoint("ws://localhost:26657/websocket"),
WithSeiHTTPEndpoint("http://localhost:26657"),
)
if err != nil {
log.Fatal(err)
}
waterway.Start(ctx)| Path | Description |
|---|---|
/ |
JSON-RPC endpoint (HTTP POST or WebSocket upgrade) |
/health |
Health check with pool status |
/metrics |
Prometheus metrics |
Configure via Option functions passed to NewWaterway():
WithListenAddr— Server bind addressWithSeiWSEndpoint— Upstream WebSocket URLWithSeiHTTPEndpoint— Upstream HTTP URLWithAllowedMethods/WithBlockedMethods— Method filteringWithHTTPOnlyMethods— Force specific methods to use HTTPWithCacheableMethods— Enable caching for specific methodsWithMemcachedServers— Memcached server addressesWithMaxWSConnections— WebSocket pool sizeWithTLS— TLS certificate and key paths
- Incoming requests are validated against JSON-RPC 2.0 spec and method filters
- Cacheable methods check Memcached first
- Subscription methods (
eth_subscribe/eth_unsubscribe) always use WebSocket - Other methods try WebSocket first, falling back to HTTP on failure
- Methods that consistently fail over WebSocket are automatically routed to HTTP