Install
Building the client
Here’s a client with every option set:.APIKey() below or the ORBITFLARE_LICENSE_KEY environment variable. The URL falls back to the ORBITFLARE_GRPC_URL environment variable.
Builder methods
.URL(url) - The primary gRPC endpoint. Falls back to ORBITFLARE_GRPC_URL. Use http:// for plaintext HTTP/2 and https:// for TLS.
.URLs(urls...) - Primary + fallbacks in one call. First element is primary.
.FallbackURL(url) / .FallbackURLs(urls...) - Add fallback endpoints. On connection failure, the SDK rotates through them.
.APIKey(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 environment variable.
.Retry(policy) - Controls reconnection backoff. When a connection drops, the SDK waits InitialDelay, then multiplies it each attempt (capped at MaxDelay). Set MaxAttempts to 0 for infinite retries. Default: 100ms initial, 30s max, 2x multiplier, infinite.
.Timeout(duration) - Connection/dial timeout. Default: 30s.
.Keepalive(duration) - HTTP/2 keepalive interval. The client pings the connection at this interval and drops it if the ping is not answered within 10 seconds, which catches connections a proxy or NAT dropped silently. Default: 20s.
.PingInterval(duration) - How often the SDK sends proto-level Ping messages to the server. The server should respond with a Pong. Default: 10s.
.MaxMissedPongs(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.
.ChannelCapacity(n) - The bounded channel between the background goroutine and your code. If your code is slow to consume events, the background goroutine blocks when this fills up instead of eating unlimited memory. Default: 4096.
.MaxDecodingMessageSize(bytes) - The largest message the client accepts. Default: 64 MiB. grpc-go’s own default of 4 MiB rejects some blocks.
.Logger(logger) - A *slog.Logger for connection lifecycle events. When unset, logging is controlled by ORBITFLARE_LOG.
Building a subscription
Filters are built programmatically withSubscribeRequestBuilder and the typed filter types. A transaction matches if it involves any AccountInclude address; AccountExclude removes matches; AccountRequired means every listed address must be present.
Filter types
NewTransactionFilter()-Vote(bool),Failed(bool),Signature(string),AccountInclude(...),AccountExclude(...),AccountRequired(...).NewAccountFilter()-Account(...),Owner(...),Datasize(uint64),TokenAccountState(bool),Memcmp(...),Lamports(...),NonemptyTxnSignature(bool).NewSlotFilter()-FilterByCommitment(bool),InterslotUpdates(bool).NewBlockFilter()-AccountInclude(...),IncludeTransactions(bool),IncludeAccounts(bool),IncludeEntries(bool).NewBlockFooterFilter()-IncludeCertificates(bool). See Block footers.NewDeshredTransactionFilter()-Vote(bool),AccountInclude(...),AccountExclude(...),AccountRequired(...).
Memcmp is built with geyser.MemcmpBytes(offset, []byte), geyser.MemcmpBase58(offset, string), or geyser.MemcmpBase64(offset, string). Lamports with geyser.LamportsEq/Ne/Lt/Gt(uint64). Commitment is one of geyser.Processed, geyser.Confirmed, geyser.Finalized.
Subscribe also accepts a raw *geyser.SubscribeRequest (a re-export of the proto type) if you’d rather build it by hand.
Reading the stream
Subscribe returns a *geyser.Stream. Call Next(ctx) to get the next update:
Next(ctx) blocks until an event arrives. It returns io.EOF once the stream has ended (including after Close); any other non-nil error is fatal for that stream. It also returns ctx.Err() if the context is cancelled. Pong messages are consumed internally and never appear in your stream.
A fatal error means 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. Match them with errors.As(err, &grpcErr) on a *orbitflare.GRPCError. Only a connection that delivered a message resets the retry count.
Closing
client.Close() stops every stream the client started.
Block footers
Alpenglow block footers arrive as their ownBlockFooter update as soon as the validator reports them, without waiting for the block. Join them with other per-block updates on (Slot, BankId). Certificates are opt-in, and their BLS signatures are not verified:
Resuming after a reconnect
Subscribe sends the same request on every reconnect. SubscribeWith 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:
LastSlot + 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 FromSlot, 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 handle that can be passed to other goroutines:
FromSlot is ignored on an update. A stream opened with Subscribe keeps the updated request for later reconnects; one opened with SubscribeWith 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:Lagged instead. The first call to Events() also returns what happened before it was called. Recv(ctx) waits for the next event and TryRecv() returns at once.
Multiple streams
One client can run many streams at once. Each gets its own background connection:Update, rather than opening a stream per filter. See connection limits.