Somnia makes event-driven smart contracts possible. ROP turns that primitive into an automation rail.
ROP is a hackathon-grade monorepo for the Somnia Reactivity Mini Hackathon. It packages a general rule protocol, a reactive watcher/dispatcher, and a clean frontend around one flagship demo: Reactive Guardian, a DeFi protection workflow that creates on-chain rules for price drops and vault-health deterioration.
ROP models automation as reusable rules:
WHEN on-chain trigger X happens AND condition Y is true THEN execute action Z
The current MVP includes:
RuleRegistryfor storing trigger, condition, action, and execution limitsReactiveExecutorfor cooldown enforcement, daily execution caps, and action dispatch- Action modules for
WITHDRAW_FROM_VAULT,SWAP_TO_STABLE, andEMIT_ONLY - A watcher that subscribes to Somnia Reactivity in real mode and simulates that callback path in mock mode
- A Next.js UI for templates, rule creation, user rule inventory, and live execution receipts
ROP is intentionally built around Somnia’s native reactivity model instead of polling:
- The watcher subscribes to on-chain events in real time
- In real mode, the Somnia adapter can bundle view calls with event subscriptions so callback data includes fresh chain state
- In mock mode, the same rule engine runs against local contract events for deterministic demos
- Execution still lands on-chain through
ReactiveExecutor, so the demo shows both reactive detection and protocol-level execution
High-level flow:
- The user creates one or more rules in
RuleRegistry - Somnia Reactivity pushes matching events into the watcher
- The watcher normalizes the event, suppresses duplicates, loads candidate rules, and evaluates conditions
- If a rule matches, the watcher submits
ReactiveExecutor.fire(ruleId, triggerPayload) - The executor enforces cooldown and daily caps, then calls an action module
- The watcher streams execution receipts to the UI over SSE
See ARCHITECTURE.md for the detailed diagram.
/apps
/contracts Hardhat contracts, deploy scripts, and tests
/watcher Somnia Reactivity watcher and SSE feed
/web Next.js UI
/scripts Guided demo and utility scripts
/packages
/shared ABIs, schemas, constants, and demo data
/docs Architecture, reactivity, security, demo, and submission docs
pnpm installTerminal 1:
pnpm --filter @rop/contracts exec hardhat nodeTerminal 2:
pnpm deploy:local
pnpm seed:demoTerminal 3:
pnpm dev:watcherTerminal 4:
pnpm dev:webCopy the addresses from deployments/localhost.json into apps/web/.env.local and apps/watcher/.env.local.
pnpm build
pnpm test
pnpm lint
pnpm demoDefaults:
- Chain ID:
50312 - RPC:
https://dream-rpc.somnia.network/
Steps:
- Fill
.envwithPRIVATE_KEY_DEPLOYERandPRIVATE_KEY_WATCHER - Run
pnpm deploy:testnet - Copy
deployments/somniaTestnet.jsonaddresses into the watcher and web env files - Run
pnpm dev:watcher - Run
pnpm dev:web
apps/watcher/src/reactivity.tsis the official Somnia integration boundaryREALmode uses@somnia-chain/reactivityMOCK_MODE=trueswaps that adapter for deterministic local subscriptions inapps/watcher/src/mock-mode.ts- Both adapters normalize their callbacks into the same rule evaluation path
More detail lives in REACTIVITY.md.
The hackathon story is simple:
- Create a Guardian rule pair
- Show the live feed waiting
- Drop the price or degrade health factor
- Watch the watcher receive the event and submit execution
- Show
RuleFiredplus updated balances - Demonstrate cooldowns or disablement
See DEMO.md for the exact recording script.
This MVP deliberately uses a trusted watcher relay. That keeps the architecture tight for the hackathon while still letting the rule protocol, execution receipts, and action-module model be credible. Guardrails include:
- cooldowns
- max executions/day
- duplicate event suppression
- explicit action-module allowlisting by address
Details: SECURITY.md
- richer trigger filters and state-aware conditions
- rule marketplaces and protocol-authored strategy packs
- decentralized executor set
- analytics over trigger and action graphs
- agent-authored automation recipes on top of the same rule rail