High Availability Provider is a load balancer for Ethereum and Solana JSON-RPC nodes, designed to provide reliable and 24/7 uninterrupted access to blockchains.
-
Zero downtime - RPC providers can and will have trouble providing you uninterrupted 24/7 access. You should have at least two providers powering your access to a chain, like your own node and a service like Infura as a backup.
-
You run your own node and you don't want to disrupt your service when you take it down for maintenance/upgrades.
-
You don't want to deal with the maintenance and costs of your own nodes for storage intensive Ethereum L2 chains or a local Solana node with high hardware requirements
- High Availability: Move any fallback logic from your application layer and rely on one RPC endpoint
- Automatic Failover: Handles request failures and forwards to the next available node or node provider
- Traffic Observability: Monitor and analyze your RPC traffic patterns
- Request Validation: Validates requests and responses to detect errors
- Rate Limit Handling: Detects rate limits and retries once the provider is available again
- Connection Optimization: Upstream keepalive/http2 connection pooling
- Health Checks: Automatic health monitoring of all configured providers
- Response caching
- Transaction broadcasts to multiple nodes
- Fetching transactions from any node that has the transaction in the mempool
- Cross checking account balances
# Using Go
go install github.com/wille/haprovider
# Using Docker
docker pull ghcr.io/wille/haprovider
- Create a configuration file
config.yml
:
endpoints:
ethereum:
kind: eth
chainId: 1
providers:
- name: Local node
http: http://localhost:8145
ws: ws://localhost:8146
- name: backup
http: https://eth.llamarpc.com
- Start the service:
$ haprovider
Or with command line options:
$ haprovider --config config.yml --log-level debug --log-json
- Connect your application:
import { ethers } from 'ethers';
// ethers.js v6
const provider = new ethers.JsonRpcProvider('http://localhost:8080/eth');
// or
const provider = new ethers.WebSocketProvider('ws://localhost:8080/eth');
The configuration file supports the following options:
# Global settings
port: 8080
log_level: info # debug, info, warn, error
log_json: false # Enable JSON logging
# Endpoint configurations
endpoints:
ethereum:
kind: eth
chainId: 1
providers:
- name: Local node
http: http://localhost:8145
ws: ws://localhost:8146
timeout: 10s
- name: Infura
http: https://mainnet.infura.io/v3/<api-key>
ws: wss://mainnet.infura.io/ws/v3/<api-key>
solana:
kind: solana
providers:
- name: quicknode
http: https://solana-mainnet.quicknode.pro/<api-key>
port
: HTTP/WS server port (default: 8080)metrics_tab
: Prometheus port (default: none)log_level
: Logging level (debug, info, warn, error)log_json
: Enable JSON logsendpoints
: Map of endpoint configurationskind
: Provider type (eth, solana) (default: solana)chainId
: Network chain ID (optional, Ethereum only)providers
: List of provider configurationsname
: Provider identifierhttp
: HTTP endpoint URL (required)ws
: WebSocket endpoint URL (optional)timeout
: Request timeout (optional, default 10s)public
: If this endpoint is available to the public. A public endpoint will not include detailed error messages and headers (optional, default false)add_xfwd_headers
Add X-Forwarded-For to upstream requests (optional)
--config
: Path to config file (default: config.yml) ($HA_CONFIG_FILE or raw yml with $HA_CONFIG)--port
: HTTP/WS server address (default: :8080) ($HA_PORT)--metrics-port
: Prometheus port (default: none) ($HA_METRICS_PORT)--log-level
: Logging level (debug, info, warn, error) (default: info) ($HA_LOG_LEVEL)--log-json
: Enable JSON logging (default: false) ($HA_LOG_JSON)
Note
Command line arguments take precedence over configuration file settings. For example, if you specify --log-level debug
on the command line, it will override the log_level
setting in the config file.
endpoints:
ethereum:
kind: eth
chainId: 1
providers:
- name: Local node
http: http://localhost:8145
ws: ws://localhost:8146
- name: Infura
http: https://mainnet.infura.io/v3/<api-key>
ws: wss://mainnet.infura.io/ws/v3/<api-key>
- name: QuickNode
http: https://mainnet.quicknode.pro/<api-key>
ws: wss://mainnet.quicknode.pro/<api-key>
endpoints:
solana:
kind: solana
providers:
- name: quicknode
http: https://solana-mainnet.quicknode.pro/<api-key>
- name: fallback
http: https://solana.rpc.helius.network
haprovider exposes Prometheus metrics for monitoring:
haprovider_requests_total
: Total number of requestshaprovider_failed_requests_total
: Failed requestshaprovider_request_duration_seconds
: Request duration histogramhaprovider_open_connections
: Open connectionshaprovider_provider_health
: Provider health statushaprovider_provider_errors_total
: Total provider errors
Enable metrics with configuration option metrics_port: 127.0.0.1:8080
Contributions are welcome! Please feel free to submit a Pull Request.