Skip to main content

Install

https:// endpoints also need the tls feature: cargo add orbitflare-sdk --features grpc,tls.

Building the client

Here’s a client with every option set:
Minimal setup:

Builder methods

.url(url) - The primary gRPC endpoint. Falls back to ORBITFLARE_GRPC_URL env var.
.urls(&[...]) - Primary + fallbacks in one call. First element is primary.
.fallback_url(url) / .fallback_urls(&[...]) - Add fallback endpoints. On connection failure, the SDK rotates through them.
.api_key(key) - Your license key, sent as the x-token header on every call. Required when your license is in API Key Only mode. In IP Whitelist mode, leave it out. Falls back to the ORBITFLARE_LICENSE_KEY env var.
.retry(policy) - Controls reconnection backoff. When a connection drops, the SDK waits initial_delay, then doubles it each attempt (capped at max_delay). Set max_attempts to 0 for infinite retries. Default: 100ms initial, 30s max, 2x multiplier, infinite.
.timeout_secs(n) - Per-request gRPC timeout. Default: 30.
.keepalive_secs(n) - TCP keepalive interval. The OS sends probes at this interval to detect dead connections at the TCP level. Default: 60. Independently of this, the SDK sends HTTP/2 keepalive pings every 20 seconds and drops a connection that does not answer within 10.
.ping_interval_secs(n) - How often the SDK sends proto-level Ping messages to the server. The server should respond with a Pong. Default: 10.
.max_missed_pongs(n) - How many consecutive pings can go unanswered before the SDK considers the connection dead and reconnects. Default: 3. With the defaults, a dead connection is detected within 30 seconds.
.channel_capacity(n) - The bounded channel between the background task and your code. If your code is slow to consume events, the background task blocks when this fills up instead of eating unlimited memory. Default: 4096.
.max_decoding_message_size(bytes) - The largest message the client accepts. Default: 64 MiB. tonic’s own default of 4 MiB rejects some blocks.

Writing a YAML config

Create a YAML file with the filters you want:

YAML filter reference

transactions - each entry is a named filter. A transaction matches if it involves any of the account_include addresses. account_exclude removes matches. account_required means all listed addresses must be present. vote and failed filter by transaction type. accounts - watch specific accounts by address, or watch all accounts owned by a program via owner. slots - subscribe to slot updates. filter_by_commitment only sends updates at your commitment level. commitment - "processed", "confirmed", or "finalized". Defaults to "confirmed". The YAML supports ${ENV_VAR} expansion:

Subscribing and reading events

From YAML

Programmatically

For dynamic filters built at runtime:
Leave ping unset: Yellowstone treats a request carrying a ping as a ping only and ignores its filters. The SDK sends its own pings. SubscribeRequestBuilder builds the same request with typed filters (TransactionFilter, AccountFilter, SlotFilter, BlockFilter, BlockFooterFilter, DeshredTransactionFilter):

Reading the stream

Both subscribe_yaml and subscribe return a GeyserStream. Call .next() to get the next event:
stream.next() blocks until an event arrives. Returns None when the stream is closed. Each event is a Result - an Err means the stream has ended for good: either all retries were exhausted, or the server rejected the request as invalid, unauthenticated, forbidden or unimplemented. Those rejections end the stream at once instead of being retried, since the same request would fail again. Only a connection that delivered a message resets the retry count. Pong messages are consumed internally and never appear in your stream.

Closing

Stops the background task immediately. Or just drop the stream.

Block footers

Alpenglow block footers arrive as their own UpdateOneof::BlockFooter update as soon as the validator reports them, without waiting for the block. Join them with other per-block updates on (slot, bank_id). Certificates are opt-in, and their BLS signatures are not verified:

Resuming after a reconnect

subscribe sends the same request on every reconnect. subscribe_with builds the request for each connection instead, so a reconnect can resume from where the stream left off and pick up your current filters. The callback gets the endpoint, the attempt number, whether this is a reconnect, and the highest slot the stream has seen:
Resume a few slots back rather than at last_slot + 1: the last slot may have been cut off part way through, and the replay sends its remaining updates again, so deduplicate by signature. When a request sets from_slot, the stream first asks the server how far back it can replay. A slot older than that starts at the oldest available one, and a server without replay starts live, instead of failing the subscription. Both are reported as connection events.

Changing filters on a live stream

Yellowstone applies a new request on an open stream in place of the previous one, so filters can change without reconnecting and without missing anything in between. update sends one; handle() gives a cloneable handle that works from any task:
from_slot is ignored on an update. A stream opened with subscribe keeps the updated request for later reconnects; one opened with subscribe_with calls its callback, which should reflect the change.

Connection events

Reconnects are invisible in the update stream itself. Every stream also reports its connection lifecycle, for health checks, metrics, or deciding a gap needs backfilling:
Events never hold the stream back: a reader that falls behind by more than 256 events gets Lagged instead. The first call to events() also returns what happened before it was called. try_recv() returns at once instead of waiting.

Multiple streams

One client can run many streams at once. Each gets its own background connection:
They share endpoint health state - if one stream quarantines a failing endpoint, the others skip it on their next reconnect. But their connections and lifecycles are fully independent. Because every stream is its own connection, Yellowstone’s limit of 5 connections per IP per region also caps you at 5 streams. Put several named filters on one stream, and change them with update, rather than opening a stream per filter. See connection limits. You can spin up new streams at any time, including dynamically based on data from an existing stream.

Full example

A stream that watches pump.fun transactions, decodes the signature, and prints a summary for each one.
With this grpc.yml: