docs: add comprehensive README for Nostr State Machines project
gzuuus
347afe55
8 days ago

README.md

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

  1. State Machine Definition (kind: 7500): Immutable event containing the state machine specification

  2. State Snapshot (kind: 30078): Replaceable event storing current state

  3. Transition 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: 7502 events

  • Gift Wrap Events: All state machine events encrypted using kind: 1059

  • Participant 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.

Repository Details

name / identifier

nsm

nostr clone url

nostr://npub1gzuushllat7pet0ccv9yuhygvc8ldeyhrgxuwg744dn5khnpk3gs3ea5ds/relay.ngit.dev/nsm
just install ngit and run
git clone nostr://...
description
none

git servers

https://relay.ngit.dev/npub1gzuushllat7pet0ccv9yuhygvc8ldeyhrgxuwg744dn5khnpk3gs3ea5ds/nsm.git
https://gitnostr.com/npub1gzuushllat7pet0ccv9yuhygvc8ldeyhrgxuwg744dn5khnpk3gs3ea5ds/nsm.git

maintainers

earliest unique commit

d7921d06525065419c6ad9a5dc33490a9f657fbd

gitworkshop.dev logo GitWorkshop.dev v2025-11-18+415c352