Hyperstack is a real-time streaming data pipeline for Solana that transforms on-chain events into typed state projections. Instead of building infrastructure, you declare what data you need, and Hyperstack handles all the complexity.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hypertekorg/hyperstack/llms.txt
Use this file to discover all available pages before exploring further.
The Problem
Building data pipelines for Solana apps is painful:- Manual parsing - You write custom code to decode accounts and instructions
- ETL complexity - You build pipelines to transform, aggregate, and store data
- RPC overhead - You manage websocket connections, retries, and state sync
- Type mismatches - On-chain types don’t match your app types
The Hyperstack Solution
Instead of building infrastructure, you declare what data you need:- Subscribes to the relevant on-chain events
- Transforms raw data into your entity shape
- Streams updates to your app as they happen on-chain
- Generates type-safe SDKs for your frontend
Architecture Overview
Key Components
Specification (AST)
Your stream definition is written in Rust using procedural macros. During compilation, these macros generate an Abstract Syntax Tree (AST) that describes:- Entities - The data structures you want
- Handlers - Which on-chain events to listen for
- Mappings - How to extract and transform data
- Field Types - Complete type information for SDK generation
.hyperstack/*.stack.json) and deployed to the runtime.
Compiler
The compiler transforms the AST into optimized bytecode:- OpCodes - Low-level VM instructions (LoadEventField, SetField, etc.)
- Handlers - Event routing tables by type
- State Tables - Entity storage configuration
- Computed Fields - Expression evaluation hooks
Virtual Machine (VM)
The VM executes bytecode to process blockchain events: State Management:- State Tables - LRU-cached entity storage (default: 2,500 entries per entity)
- Lookup Indexes - Fast key resolution for cross-entity references
- Temporal Indexes - Time-based entity lookups with TTL
- PDA Reverse Lookups - Map PDAs back to seeds
- Events arrive via Yellowstone gRPC
- VM routes to handlers by event type
- Handlers execute bytecode:
- Extract fields from event data
- Resolve primary keys (embedded, lookup, computed, or temporal)
- Apply transformations and population strategies
- Update state tables
- Queue resolver requests for async enrichment
- Dirty tracking captures only changed fields
- Mutations stream to connected clients
- Account updates: Lexicographic comparison on
(slot, write_version) - Instruction updates: Exact deduplication via
(slot, txn_index) - Stale updates are rejected silently
Streaming
The streaming layer provides real-time updates to clients:- WebSocket Protocol - Bidirectional JSON messages
- View Subscriptions - Client subscribes to entity views
- Delta Updates - Only changed fields are transmitted
- Append Tracking - Array appends send only new items
Data Flow
Specification Time
- Write stream definition using
#[hyperstack]macro cargo buildgenerates AST (.hyperstack/*.stack.json)- Deploy with
hs up(uploads AST to runtime) - Runtime compiles AST to bytecode
Runtime
- Event Ingestion: Solana events arrive via Yellowstone gRPC
- Event Routing: VM routes events to entity handlers by type
- Handler Execution: Bytecode executes:
- Extract fields from event payload
- Resolve entity primary key
- Load or initialize entity state
- Apply mappings with population strategies
- Evaluate computed fields
- Track dirty fields
- State Update: Modified entities saved to state table
- Mutation Emission: Delta patches stream to clients
Client
- Connect to WebSocket endpoint
- Subscribe to views (e.g.,
Token/list,Token/state) - Receive snapshot of current state
- Receive live delta updates as mutations
- SDK merges deltas into local state
- React components re-render automatically
Processing Model
Handlers
Each entity can have multiple handlers, one per event type (account or instruction):CreateIxinstruction → extractsmintBondingCurveaccount → extractssol_reservesBuyIxinstruction → sumsamountintototal_volume
Population Strategies
Strategies control how field values are updated over time:| Strategy | Behavior | Use Case |
|---|---|---|
SetOnce | Set once, never overwrite | Immutable data (mint address) |
LastWrite | Always use latest value | Current state (price, balance) |
Append | Collect into array | Event history |
Sum | Running total | Cumulative metrics |
Count | Increment counter | Event counts |
Min/Max | Track extremes | High/low values |
UniqueCount | Count distinct values | Unique traders |
Key Resolution
Every entity has a primary key that uniquely identifies it. Hyperstack supports four resolution strategies: 1. Embedded - Key is extracted directly from event data:Type Safety
Hyperstack provides end-to-end type safety:- Spec Types - Rust ensures valid mappings at compile time
- AST Types - Complete type information captured in AST
- Generated SDKs - TypeScript/Python types match Rust definitions
- Runtime Validation - Data conforms to expected shapes
Performance Characteristics
Memory Management
- State Tables: LRU-cached, default 2,500 entities per table
- Lookup Indexes: LRU-cached, 2,500 entries per index
- Temporal Indexes: 2,500 keys, max 250 entries per key, 5-minute TTL
- PDA Reverse Lookups: 2,500 entries
- Pending Queue: Max 2,500 total updates, 50 per PDA, 5-minute TTL
Optimizations
- Path Caching: Field paths compiled once and cached
- Dirty Tracking: Only changed fields trigger mutations
- Delta Transmission: Append operations send only new items
- Bytecode Compilation: AST compiled to optimized opcodes
Next Steps
Architecture
Deep dive into system components
Entities
Learn about entity definitions
Mappings
Understand field mapping strategies
Streams
Stream definitions and lifecycle