Skip to main content

Install

Building the client

Here’s a client with every option set:
Minimal setup:
gRPC needs no API key. 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.
.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) - TCP/HTTP2 keepalive interval, used to detect dead connections at the transport level. Default: 60s.
.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.
.Logger(logger) - A *slog.Logger for connection lifecycle events. When unset, logging is controlled by ORBITFLARE_LOG.

Building a subscription

Filters are built programmatically with SubscribeRequestBuilder 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).
  • 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.

Closing

Stops the background goroutine immediately. client.Close() stops every stream the client started.

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. You can spin up new streams at any time.

Full example

A stream that watches pump.fun transactions and prints a summary for each one.