Install
@grpc/grpc-js and yaml are optional peer dependencies. Install them only if you use the gRPC client (or YAML config).
Building the client
Here’s a client with every option set: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.
.fallbackUrl(url) / .fallbackUrls([...]) - Add fallback endpoints. On connection failure, the SDK rotates through them.
.retry(policy) - Controls reconnection backoff. When a connection drops, the SDK waits initialDelayMs, then doubles it each attempt (capped at maxDelayMs). Set maxAttempts to 0 for infinite retries. Default: 100ms initial, 30s max, 2x multiplier, infinite.
.timeoutSecs(n) - Per-request gRPC timeout. Default: 30.
.keepaliveSecs(n) - TCP keepalive interval. The OS sends probes at this interval to detect dead connections at the TCP level. Default: 60.
.pingIntervalSecs(n) - How often the SDK sends proto-level Ping messages to the server. The server should respond with a Pong. Default: 10.
.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 buffer between the background task and your code. If your code is slow to consume events, the background task pauses when this fills up instead of eating unlimited memory. Default: 4096.
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:Reading the stream
BothsubscribeYaml and subscribe return a GeyserStream. It’s an async iterable - use for await:
await stream.next() directly to pull one event at a time. Returns undefined when the stream is closed. If retries are exhausted, the next iteration throws.
Pong messages are consumed internally and never appear in your stream.
Closing
Multiple streams
One client can run many streams at once. Each gets its own background connection:Full example
A stream that watches pump.fun transactions, decodes the signature, and prints a summary for each one.grpc.yml: