On-Chain Reactivity

circle-exclamation

Blockchains have historically had a major limitation: they are passive. They are excellent ledgers, but they are deaf and mute until a user kicks them into action with a transaction. A smart contract cannot "wake up" when a price changes, specific data shows up or when a specific event occurs.

The Usability

Imagine the world where you can instantly react to events happening on blockchain:

  • DeFi: Automated responses to price changes, liquidations, or interest accruals. For instance, a lending protocol might need to adjust collateral requirements instantly based on market volatility.

  • Gaming: Real-time updates for player achievements, in-game economies, or multiplayer interactions. Imagine a blockchain game where earning an NFT trophy automatically triggers rewards or level-ups without off-chain servers.

  • Business Logic: Supply chain tracking where an item's arrival (logged as an event) auto-initiates payments or audits. Or in insurance, a smart contract that pays out claims upon verified on-chain data like weather reports.

The Setup

The blockchain is ledger of transaction modifying the common state. Some of these transaction might emit a log, which is defined as an observable event:

spinner

Traditionally the developer would need to create an infrastructure that constantly monitors the blockchain state and event through RPC calls. Then based on the logic the custom app would create a transaction and post it for the inclusion at the next available block:

spinner

As expected this created a large overhead for a typical development team. Additionally it did not meet the requirements of decentralisation, trustlessness, immediate reaction and reliable event handling.

This is why we saw a plethora of services known as indexers or Web3 hooks:

spinner

They alleviate a lot of issues related to the infrastructure, at the same time they add new issues related to the domain-specific configuration or language. Still the key requirements are still not met:

  • indexers are centralised and trustfull

  • the event handling trasaction can only be included in the next available block

  • it is not MEV-resistant

  • it's only as reliable as the indexer provider

The Solution

Enter Somnia Native On-Chain Reactivity.

This isn't just an incremental improvement; it's a paradigm shift that enables real-time, trustless and decentralised reactions without relying on external systems:

spinner

The Benefits

Once an event is defined, it's handling is happening automatically by blockchain nodes:

  • Real-Time: Reaction included in the same block.

  • Decentralised: As decentralised as the blockchain itself.

  • Trustlessness: No trusted party required.

  • MEV: Fully MEV-resistant due to deterministic inclusion of event handlers

  • Developer-Friendly: Familiar paradigms (e.g., subscriptions akin to event listeners in traditional programming) and interface reduce complexity.

  • Cost Efficiency: Optimized gas usage minimize expenses compared to infrastucture required for constant off-chain monitoring.

  • Security and Resilience: Backed by the blockchain itself. Reduces attack surfaces by eliminating external dependencies; nested events allow complex chains without intermediaries.

  • Scalability: Supports high-throughput apps, as seen in Somnia's 1M+ TPS capability, making it ideal for mass-adoption scenarios.


Comparison Table

Aspect
Traditional RPC
Indexer/Hooks
Somnia Reactivity

Timing

Next block

Next block

Same block

Decentralization

Developer infra

Centralized service

Fully decentralized

Trust Model

Self-hosted

Trusted third party

Trustless

MEV Resistance

Infrastructure

High complexity

Medium complexity

Zero external infra

Reliability

Self-managed

Service-dependent

Blockchain-native

Last updated