Skip to content

docs(flashblocks): add WebSocket streaming guide to app-integration#1300

Open
erhnysr wants to merge 2 commits intobase:masterfrom
erhnysr:feat/flashblocks-websocket-streaming
Open

docs(flashblocks): add WebSocket streaming guide to app-integration#1300
erhnysr wants to merge 2 commits intobase:masterfrom
erhnysr:feat/flashblocks-websocket-streaming

Conversation

@erhnysr
Copy link
Copy Markdown

@erhnysr erhnysr commented Apr 13, 2026

Summary

The app-integration page documented RPC usage (viem, wagmi, ethers.js) but had no coverage of direct WebSocket streaming — a pattern commonly needed for real-time applications like address monitors, trading dashboards, and gaming apps.

Changes

Added a WebSocket Streaming section to docs/base-chain/flashblocks/app-integration.mdx covering:

  • Endpoints — mainnet and sepolia WebSocket URLs
  • Message format — explains Brotli compression, index: 0 (full block header) vs index: 1-9 (diff only), with a JSON example
  • Basic connection — minimal TypeScript example with Brotli decompression and plain JSON fallback
  • Auto-reconnect — production-ready client with exponential backoff (1s → 30s max)
  • Address watcher — real-time pattern for monitoring incoming/outgoing transactions for a specific address

Why this matters

Flashblocks' primary value proposition is sub-200ms latency. That benefit is only reachable via WebSocket — polling the RPC every 200ms defeats the purpose. Developers building real-time apps currently have no documented path to use the WebSocket stream.

Notes

  • All examples use TypeScript
  • Only dependencies are ws (npm) and Node's built-in zlib — no extra packages
  • Brotli decompression is documented explicitly since it's a non-obvious requirement that catches developers off guard

erhnysr added 2 commits April 6, 2026 22:47
Adds a clarification note about using the correct RPC endpoint when building on Base.
The app-integration page covered RPC usage (viem, wagmi, ethers) but had
no documentation for direct WebSocket streaming — a common pattern for
real-time use cases like address monitoring and mempool tracking.

Added a new WebSocket Streaming section covering:
- Endpoint URLs for mainnet and sepolia
- Flashblock message format (Brotli-compressed JSON, index 0 vs diff)
- Basic connection example with Brotli decompression
- Auto-reconnect with exponential backoff for production use
- Address watcher pattern for real-time tx monitoring

All examples are TypeScript and use only the built-in zlib module
plus the ws package — no additional dependencies required.
@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/2
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants