Subscribe to Pre-Confirmations for lowest latency
mainPre-confirmations provide an early signal of scheduled transactions before they are shredded. This is an early signal, not a guarantee, and coverage depends on the share of stake forwarding to Helius.
Use makePreconfWsClient or makePreconfWsClientForApiKey from helius-sdk/websockets/preconfWs.
Subscription Details:
preconfSubscribe(): Streams all scheduled transactions. Returns anAsyncIterableof{ version, slot, transactionIndex, status, transaction, transactionBytes }.preconfUnsubscribe(subscriptionId): Unsubscribes from the stream.
Data Format:
Notifications are binary frames. The layout is: version:u8 | slot:u64_le | transaction_index:u64_le | status:u8 | bincode(VersionedTransaction).
statusis aPreconfStatusenum:Failed = 0,Success = 1,Unknown = 2.
Endpoint: Served from wss://beta.helius-rpc.com/?api-key=<KEY> (Production path).
import { makePreconfWsClientForApiKey } from "helius-sdk/websockets/preconfWs";
const client = makePreconfWsClientForApiKey(apiKey);
const sub = await client.preconfSubscribe();
for await (const event of sub) {
// event.transaction is the decoded @solana/kit Transaction; event.transactionBytes is the raw bincode payload
console.log(event.version, event.slot, event.transactionIndex, event.status);
}
await sub.unsubscribe();
client.close();