Velox quick start
Stream processed Solana transactions from Velox over Yellowstone gRPC in TypeScript or Rust, reply to pings, and reconnect without from_slot.
This gets you a processed transaction stream filtered on one program, in TypeScript or Rust.
| You need | Where it comes from |
|---|---|
| Velox bought for your metro and server IP (listed as Premium gRPC) | Dashboard; see the four endpoints |
| A client running on that server IP | Your registered public egress IP is the credential; there is no x-token |
| Node.js 20 or newer, or a Rust toolchain | — |
Pick TLS or plaintext with the scheme. Both reach the same port:
# TLS
export VELOX_ENDPOINT='https://velox.fra.corvus-labs.io:40404'
# Plaintext
export VELOX_ENDPOINT='http://velox.fra.corvus-labs.io:40404'Install a client
npm install @triton-one/yellowstone-grpc@^9 bs58Use @triton-one/yellowstone-grpc 9.0.0 or newer: older releases lack the typed block-footer certificate fields.
[dependencies]
anyhow = "1"
bs58 = "0.5"
futures = "0.3"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
yellowstone-grpc-client = "15"
yellowstone-grpc-proto = "14"
# tonic leaves rustls without a crypto provider; this one is installed in main().
rustls = { version = "0.23", default-features = false, features = ["ring"] }These are the releases that ship with Yellowstone v16.1.4, the version Velox serves. A plain tonic client generated from the Velox protos works too. Without the rustls line and its install_default() call, an https:// connection panics with "Could not automatically determine the process-level CryptoProvider".
Subscribe to processed transactions
Create subscribe.ts:
import Client, { CommitmentLevel } from '@triton-one/yellowstone-grpc';
import bs58 from 'bs58';
const PUMP_FUN = '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P';
async function main() {
const endpoint = process.env.VELOX_ENDPOINT;
if (!endpoint) {
throw new Error('Set VELOX_ENDPOINT');
}
// No x-token. An https:// endpoint connects over TLS, http:// in plaintext.
const client = new Client(endpoint, undefined, {
grpcMaxDecodingMessageSize: 64 * 1024 * 1024,
});
await client.connect();
const stream = await client.subscribe();
stream.on('data', (update) => {
if (update.transaction) {
const { slot, transaction } = update.transaction;
console.log('transaction', {
slot,
signature: bs58.encode(transaction.signature),
filters: update.filters,
});
}
// The server pings every 10 seconds. Reply on the same stream.
if (update.ping) {
stream.write({ ping: { id: 1 } });
}
});
stream.on('error', (error) => {
console.error('Velox stream failed', error);
});
stream.on('end', () => {
console.log('Velox stream ended');
});
stream.write({
transactions: {
pumpfun: {
vote: false,
failed: false,
accountInclude: [PUMP_FUN],
accountExclude: [],
accountRequired: [],
},
},
commitment: CommitmentLevel.PROCESSED,
});
}
main().catch((error) => {
console.error(error);
process.exit(1);
});Run it:
npx tsx subscribe.tsCreate src/main.rs:
use {
futures::{sink::SinkExt, stream::StreamExt},
std::collections::HashMap,
yellowstone_grpc_client::{ClientTlsConfig, GeyserGrpcClient},
yellowstone_grpc_proto::prelude::{
subscribe_update::UpdateOneof, CommitmentLevel, SubscribeRequest,
SubscribeRequestFilterTransactions, SubscribeRequestPing,
},
};
const PUMP_FUN: &str = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// tonic's TLS needs a process-wide rustls crypto provider; install it before connecting.
let _ = rustls::crypto::ring::default_provider().install_default();
let endpoint = std::env::var("VELOX_ENDPOINT")?;
// No x-token. tonic needs an explicit TLS config for https://; http:// stays plaintext.
let mut builder = GeyserGrpcClient::build_from_shared(endpoint.clone())?
.max_decoding_message_size(64 * 1024 * 1024);
if endpoint.starts_with("https://") {
builder = builder.tls_config(ClientTlsConfig::new().with_native_roots())?;
}
let mut client = builder.connect().await?;
let request = SubscribeRequest {
transactions: HashMap::from([(
"pumpfun".to_owned(),
SubscribeRequestFilterTransactions {
vote: Some(false),
failed: Some(false),
account_include: vec![PUMP_FUN.to_owned()],
..Default::default()
},
)]),
commitment: Some(CommitmentLevel::Processed as i32),
..Default::default()
};
let (mut sink, mut stream) = client.subscribe_with_request(Some(request)).await?;
while let Some(update) = stream.next().await {
let update = update?;
match update.update_oneof {
Some(UpdateOneof::Transaction(tx)) => {
let signature = tx
.transaction
.as_ref()
.map(|info| bs58::encode(&info.signature).into_string());
println!("transaction slot={} signature={signature:?} filters={:?}", tx.slot, update.filters);
}
// The server pings every 10 seconds. Reply on the same stream.
Some(UpdateOneof::Ping(_)) => {
sink.send(SubscribeRequest {
ping: Some(SubscribeRequestPing { id: 1 }),
..Default::default()
})
.await?;
}
_ => {}
}
}
Ok(())
}Run it:
cargo runpumpfun is a filter name you picked; filters on each update lists every one of your filters it matched. A ping-only write carries no filters, so it leaves your subscription alone; any other write replaces the whole subscription, so always send the complete filter set.
Verify the stream
| Symptom | Cause | Fix |
|---|---|---|
| No transactions, no error | The filter matches nothing | Widen it, or filter on a busy program like the one above |
UNAUTHENTICATED (16), detail no authenticated identity for connection | This egress IP isn't registered in this metro | Register the address your traffic actually leaves from |
PERMISSION_DENIED (7), detail identity is not scoped to the requested service | No Velox purchase for this IP in this metro | Buy Velox (Premium gRPC) for this metro and IP; reconnecting won't help |
| TLS handshake fails | https:// without TLS configured in the client, or TLS against http:// | Match the scheme to the client's credentials (regions) |
INTERNAL, from_slot is not supported | The request set from_slot | Remove it; see reconnect |
Limits lists every refusal.
Reconnect
Velox has no from_slot replay. A request that sets it fails the stream with INTERNAL and the message from_slot is not supported. That includes the clients' built-in reconnect helpers, subscribeWithReconnect in TypeScript and subscribe_with_reconnect in Rust: they resume with from_slot, so use plain subscribe and reconnect yourself.
On error or end:
- Remember the last slot you fully processed.
- Back off briefly, open a new client and a new stream, and write the complete filter set again; nothing carries over.
- Compare the first slot you receive against the slot you remembered.
- Fill the gap through Solana RPC at
confirmedorfinalized:- Filtering on an account or program: page
getSignaturesForAddressfor that address back to the last signature you handled, thengetTransactioneach one you missed. - Need every transaction: list the slots with
getBlocks(lastSlot + 1, firstNewSlot - 1)and fetch each withgetBlock.
- Filtering on an account or program: page
Solana RPC runs in all four Velox metros (http://<region>.corvus-labs.io:8899), so the gap fill stays local. Dedupe on signature: the gap and the new stream can overlap.
For liveness, use the ping: the server sends one every 10 seconds per stream. If nothing (no update, no ping) has arrived for 20 seconds, treat the stream as dead and reconnect.
Next
Velox
Executed Solana transactions, accounts, slots and blocks over Yellowstone gRPC, streamed processed-first in four metros.
Velox API
Every Velox Yellowstone gRPC method, filter map, commitment level and compression option, and what Velox does with from_slot, SubscribeReplayInfo, SubscribeDeshred and SubscribeGossip.