Key Features
Data-stream processing features include:- Windowing - fixed size, fixed time, fixed size sliding
- Aggregation - average, min, max
- Thresholding - rising edge, falling edge
- Rate limiting
Getting Started
Prerequisites
Before building your monitor, you’ll need:- A Dialect SDK instance configured with your dApp’s wallet
- A defined data type that represents what you want to monitor
Basic Setup
Building Your Monitor
1. Initialize the Monitor Builder
2. Supply Data (Poll or Push)
Use this when you want to regularly check for data changes:
3. Transform Data to Detect Events
During the transform step, streaming data is processed to identify events that should trigger notifications:Available Transformations
- Thresholding:
rising-edge
,falling-edge
- Windowing: Fixed size, fixed time, sliding windows
- Aggregation: Average, min, max operations
- Array Diff: Track additions/removals from arrays
4. Add Notification Logic
The notify step defines how to send alerts when events are detected:Dispatch Types
- unicast: Send to one specific subscriber
- multicast: Send to multiple specific subscribers
- broadcast: Send to all subscribers
5. Build and Start the Monitor
Complete Example
Here’s a full working example that monitors collateralization ratios and sends warnings:Testing Your Monitor
Step 1: Generate Test Keypair
Step 2: Start Server
Step 3: Test with Client
Hosting Your Monitor
If you already have a preferred hosting framework, you can simply deploy your monitor there and skip to setting up your notification UI/UX.
Real-World Examples
Explore these open-source implementations for inspiration:Governance / DAO
- Realms - Complex DAO and proposal monitoring
DeFi Protocols
- Jet - Liquidation warnings with thresholding
- Marinade - Notification types and broadcast features
- Saber - Push-type data sources and Twitter integration
- Investin - Multiple monitor builders for different use cases
These examples may not use the latest Dialect packages. Use them for learning, but implement your monitor with the latest dependencies for new features and bug fixes.
Advanced Features
Multiple Transforms
You can chain multiple transformations using.also()
:
Custom Pipelines
Create custom pipeline operators for specialized data processing needs. See the custom pipelines example.Rate Limiting
Built-in rate limiting prevents notification spam while ensuring important alerts get through.Next Steps
Once your monitor is built and hosted:- Set up notification UI/UX - Create user interfaces for subscription management
- Configure topics and channels - Organize your notifications
- Send additional alerts - Combine monitoring with manual alert sending