Nostr State Machines
A distributed, event-driven state machine protocol built on the Nostr network, providing verifiable, self-contained state management for complex multi-step processes.
Overview
Nostr State Machines enable the creation and management of verifiable state machines that operate in a decentralized environment. Inspired by XState and similar to saga state machines, this protocol allows developers to model complex workflows where state transitions are represented as Nostr events, creating an immutable audit trail.
Key Features
Distributed Architecture: Operates on the decentralized Nostr network without relying on centralized servers
Event-Driven: All state transitions are triggered by Nostr events (
kind: 7501)Conflict Resolution: Uses a Directed Acyclic Graph (DAG) to handle forks and ensure consistency (
state-machines-on-nostr.md0)Multiple Custodians: Any participant can act as a state custodian, enabling redundancy and verification (
state-machines-on-nostr.md)End-to-End Encryption: Optional encryption layer for private state machines (
encrypted-state-machines.md)
How It Works
Core Components
State Machine Definition (
kind: 7500): Immutable event containing the state machine specificationState Snapshot (
kind: 30078): Replaceable event storing current stateTransition Input (
kind: 7501): Regular events that trigger state changes
DAG-Based Conflict Resolution
The protocol uses a DAG structure where each transition event points to the previous transition, creating a verifiable chain. When forks occur (multiple valid transitions from the same state), the system provides mechanisms for deterministic resolution (state-machines-on-nostr.md).
Similarity to Saga State Machines
Like saga patterns, Nostr State Machines:
Manage long-running transactions across multiple steps
Provide compensation mechanisms through state transitions
Ensure consistency through event sourcing
Support distributed coordination without centralized orchestration
Scientific and Industrial Use Cases
Supply Chain Tracking
The protocol's auditability makes it ideal for supply chain applications:
Immutable Audit Trail: Every state change is permanently recorded
Multi-Party Verification: Multiple custodians can validate transitions
Transparent Process Flow: Complete visibility into shipment status changes
Dispute Resolution: Cryptographic proof of state transitions
Other Applications
Decentralized Job Boards: Track job posting to payment release
Service-Level Agreements: Automated SLA monitoring with time-based transitions
Multi-Hop Processes: Complex workflows with multiple participant roles
Arbitration Systems: Third-party oracle integration for dispute resolution
Encryption Support
For privacy-sensitive applications, the protocol supports end-to-end encryption (encrypted-state-machines.md):
Shared Key Distribution: Secure key distribution using
kind: 7502eventsGift Wrap Events: All state machine events encrypted using
kind: 1059Participant Management: Dynamic addition of new participants with full history access
Community
This protocol enables a marketplace of interoperable state machines for various use cases, from simple workflows to complex multi-party processes, all built on the robust foundation of the Nostr network.