Author: Trygve "Trig" Bundgaard (aka Ubuntu Buddha)
Real-time data pipelines for Solana with sub-second latency.
This library prioritizes:
- Event-driven architecture over polling
- Minimal latency from chain state to application
- Automatic reconnection and health monitoring
- Clean separation between data ingestion and business logic
RPC polling is slow (5-10s). This library provides:
- Event-driven updates via WebSocket
- Shred-level detection (pre-confirmation)
- Instant transaction confirmation via trade/transfer events
| Method | Latency | Notes |
|---|---|---|
| RPC polling | 5-10+ seconds | Standard getSignatureStatus loop |
| WebSocket (processed) | 5-20ms | Account change subscriptions |
| Shred detection | Pre-confirmation | Before block finalization |
| Event confirmation | <1s | Same second as on-chain, production observed |
This library may not be appropriate if:
- You only need occasional state reads
- Your use case tolerates multi-second delays
- You cannot maintain persistent WebSocket connections
- Shred-level access is not available in your infrastructure
This system has been implemented and validated in both TypeScript and Rust. The two implementations share the same architectural model but differ in execution characteristics, allowing direct comparison of throughput, latency, and operational tradeoffs under real production conditions.
| Aspect | TypeScript | Rust |
|---|---|---|
| Latency | Low | Very Low |
| Throughput | High | Very High |
| Memory Model | GC | Ownership |
| Iteration Speed | Fast | Medium |
| Ops Overhead | Lower | Medium |
The TypeScript version optimizes for:
- Faster iteration and prototyping
- Easier integration with JS-based tooling
- Operational simplicity
The Rust version optimizes for:
- Deterministic latency
- Lower tail latency under load
- Maximum throughput in critical paths
┌─────────────────────────────────────────────────────────┐
│ Application │
└────────────────────┬────────────────────────────────────┘
│
┌────────────────┼────────────────┐
│ │ │
┌───▼────┐ ┌──────▼──────┐ ┌─────▼─────┐
│ Trade │ │ Account │ │ Instant │
│ Feed │ │ Subscriber │ │ Confirm │
│ Client │ │ │ │ Service │
└────────┘ └─────────────┘ └───────────┘
│ │ │
└────────────────┼────────────────┘
│
┌────────▼────────┐
│ WebSocket │
│ Connection │
└─────────────────┘
npm install solana-realtime-dataimport { TradeFeedClient } from 'solana-realtime-data';
import { Connection } from '@solana/web3.js';
const client = new TradeFeedClient({
wsUrl: 'wss://api.example.com/trades',
apiKey: process.env.API_KEY,
});
await client.start();
client.subscribe('TokenMintAddress...');
client.on('trade', (event) => {
console.log(`Trade: ${event.signature}`);
});[dependencies]
solana-realtime-data = { path = "../solana-realtime-data/rust" }use solana_realtime_data::TradeFeedClient;
let client = TradeFeedClient::new(ws_url, Some(api_key));
client.connect().await?;
client.subscribe(mint).await?;- Trade Feed Client: DEX trade event streaming via WebSocket
- Account Subscriber: Account change subscriptions with auto-reconnect
- Instant Confirmation: Event-driven transaction confirmation
MIT