Repository navigation
Open
Description
Summary
Web contracts are currently HTTP-only. Adding Nostr as a transport layer means contracts can be discovered, read, and interacted with via Nostr relays as well as HTTP endpoints.
Why Nostr?
- Discovery — contracts published as Nostr events are discoverable across relays without knowing the host URL
- Redundancy — contract state can be mirrored across multiple relays, not dependent on a single server
- Identity alignment — contracts already use
did:nostr:<pubkey>and NIP-98 auth, so Nostr transport is a natural fit - Agent-friendly — agents already have nostr keypairs; they can subscribe to contract events and react to state changes in real-time via WebSocket
- Offline-first — submit transitions to a relay when the executor is offline; executor picks them up when back online
Possible event kinds
| Kind | Purpose |
|---|---|
30078 (or custom) |
Publish contract definition (replaceable, tagged by contract id) |
30079 (or custom) |
Publish current state (replaceable, updated each transition) |
1078 (or custom) |
Submit a transition request |
1079 (or custom) |
Transition result / receipt |
Flow
- Deploy — executor publishes contract.json + source as a Nostr event
- Discover — clients query relays by contract id tag or profile tag
- Read state — clients fetch the latest replaceable state event
- Submit transition — client publishes a transition request event, tagged with contract id
- Execute — executor subscribes to transition requests, validates, updates state, publishes new state event + receipt
- Verify — trail events reference Bitcoin anchors, verifiable by anyone
Dual transport
Contracts can support both HTTP and Nostr simultaneously:
{
"type": "WebContract",
"id": "pool-tbtc3-tbtc4",
"transport": {
"http": "https://example.com/contracts/pool-tbtc3-tbtc4/",
"nostr": {
"relays": ["wss://relay.damus.io", "wss://nos.lol"],
"pubkey": "executor-pubkey-hex"
}
}
}Benefits
- Contracts become censorship-resistant — available on any relay
- Real-time event-driven interaction via WebSocket subscriptions
- Natural fit with existing Nostr ecosystem (wallets, clients, relays)
- Executor can be a Nostr bot that listens for transition events
References
- NIP-78 — Application-specific data (arbitrary app state on relays)
- NIP-98 — HTTP Auth (already used for identity)
- Web Contracts spec: https://webcontracts.org
Metadata
Metadata
Assignees
Labels
No labels
Activity