High-performance RPC optimization for EVM (Ethereum/Base) & Solana β with both Node.js and Rust implementations.
| Metric | Node.js | Rust |
|---|---|---|
| Batch 5 RPC calls | 188ms | 53ms |
| Binary size | ~200MB | ~3MB |
| Cold start | ~500ms | Instant |
Rust is 3.5x faster for latency-critical operations like minting & arbitrage.
| Feature | Node.js | Rust | Description |
|---|---|---|---|
| Benchmark RPCs | β | β | Auto-find fastest RPC endpoint |
| Multi-RPC Failover | β | β | Auto-switch on failures |
| Request Batching | β | β | Combine calls into 1 HTTP request |
| Nonce Caching | β | β | Pre-fetch for fast tx building |
| Retry + Backoff | β | β | Exponential/Fibonacci strategies |
| Rate Limiter | β | β | Token bucket algorithm |
| Circuit Breaker | β | β | Prevent cascade failures |
| WebSocket | β | - | Real-time subscriptions |
| EVM Client | β | - | High-level ETH/Base API |
| Solana Client | β | - | High-level Solana API |
| Chain | RPCs Included |
|---|---|
| Ethereum | Llama, PublicNode, dRPC, MEVBlocker |
| Base | Base Official, Llama, PublicNode, dRPC |
| Solana | Solana Official, PublicNode, dRPC |
cd node
npm install
npm run examplecd rust
cargo build --release
cargo run --releaseimport { createEVMClient, createSolanaClient } from './src/index.js';
// Create client
const eth = createEVMClient('ethereum');
// Auto-select fastest RPC
await eth.warmup(['0xYourWallet...']);
// Use it
const block = await eth.getBlockNumber();
const balance = await eth.getBalance('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045');
console.log('Block:', block);
console.log('Balance:', balance, 'ETH');use rpc_optimizer::*;
#[tokio::main]
async fn main() {
// Benchmark and find fastest
let config = default_config();
let mut benchmark = create_benchmark();
if let Some(eth_config) = config.get("ethereum") {
benchmark.benchmark_chain("ethereum", eth_config, 3).await;
benchmark.print_results("ethereum");
}
// Batch requests
let result = batch("https://eth.drpc.org")
.get_balance("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "latest")
.block_number()
.gas_price()
.execute()
.await;
println!("Batch completed in {}ms", result.latency_ms);
}π Benchmarking Ethereum Mainnet (3 rounds each)...
Testing Llama ... β
avg: 212.8ms | p95: 212.8ms
Testing PublicNode ... β
avg: 214.7ms | p95: 263.8ms
Testing dRPC ... β
avg: 50.6ms | p95: 73.9ms
Testing MEVBlocker ... β
avg: 706.6ms | p95: 997.9ms
π Results for ETHEREUM
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Rank β Name β Avg (ms) β P95 (ms) β Min (ms) β Success
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1 β dRPC β 50.6 β 73.9 β 33.9 β 100%
2 β PublicNode β 214.7 β 263.8 β 180.6 β 100%
3 β Llama β 212.8 β 212.8 β 212.8 β 33%
4 β MEVBlocker β 706.6 β 997.9 β 555.8 β 100%
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
Fastest: dRPC (50.6ms avg)
| Use Case | Recommended |
|---|---|
| FCFS NFT Minting | Rust (microseconds matter) |
| Arbitrage Bot | Rust (latency critical) |
| MEV Bot | Rust (racing other bots) |
| Monitoring/Alerts | Node.js (easier to build) |
| Dashboard/API | Node.js (rich ecosystem) |
| Prototyping | Node.js (fast iteration) |
rpc-optimizer/
βββ node/ # Node.js implementation
β βββ src/
β β βββ index.js # Main exports
β β βββ config.js # RPC configuration
β β βββ benchmark.js # Latency testing
β β βββ failover.js # Multi-RPC failover
β β βββ batch.js # Request batching
β β βββ nonce.js # Nonce caching
β β βββ retry.js # Retry strategies
β β βββ websocket.js # WebSocket support
β β βββ chains/
β β βββ evm.js # ETH/Base client
β β βββ solana.js # Solana client
β βββ config/
β β βββ rpcs.json # RPC endpoints
β βββ examples/
β β βββ usage.js # Example usage
β βββ package.json
β
βββ rust/ # Rust implementation
βββ src/
β βββ lib.rs # Library exports
β βββ main.rs # Example runner
β βββ config.rs # RPC configuration
β βββ benchmark.rs # Latency testing
β βββ failover.rs # Multi-RPC failover
β βββ batch.rs # Request batching
β βββ nonce.rs # Nonce caching
β βββ retry.rs # Retry strategies
βββ Cargo.toml
- Fork the repo
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing) - Open a Pull Request
MIT License - feel free to use in your projects!
- bounty-radar - Bug bounty research dashboard
- github-radar - Trending GitHub repos tracker
- hf-radar - HuggingFace trending tracker
Built with β‘ by @xnotok