A Nostr relay that gates EVENT writes behind x402 sBTC micropayments. Reading is free, writing costs sats.
- WebSocket (
ws://localhost:7777) — Standard NIP-01 relay for subscriptions (REQ, CLOSE). Free. - HTTP (
http://localhost:7778) — x402-gated endpoint for publishing events. Pay sBTC to write.
npm install
npm startStandard NIP-01 protocol:
REQ— Subscribe to events (free)CLOSE— Close subscriptionEVENT— Submit events (accepted directly over WS for dev/testing)
GET /— Relay infoPOST /api/events— Publish a Nostr event (x402 payment required)
# First request returns 402 with payment details
curl -X POST http://localhost:7778/api/events \
-H "Content-Type: application/json" \
-d '{"id":"...","pubkey":"...","kind":1,"content":"hello","tags":[],"sig":"..."}'
# After paying, include tx proof
curl -X POST http://localhost:7778/api/events \
-H "Content-Type: application/json" \
-H "X-Payment-Response: {\"txId\":\"0x...\"}" \
-d '{"id":"...","pubkey":"...","kind":1,"content":"hello","tags":[],"sig":"..."}'| Kind | Cost | Description |
|---|---|---|
| 0 | 50 sats | Profile metadata |
| 1 | 10 sats | Text note |
| 4 | 5 sats | Encrypted DM |
| 30023 | 25 sats | Long-form content |
| Other | 10 sats | Default |
Payments are sBTC on Stacks, verified via the Hiro Stacks API.
Pay-to address: SP16H0KE0BPR4XNQ64115V5Y1V3XTPGMWG5YPC9TR
WS_PORT— WebSocket port (default: 7777)HTTP_PORT— HTTP port (default: 7778)
npm testMIT