Events and Protocol¶
Everything a relay stores is a signed event. Relays, indexers and clients all verify events themselves, so no component has to be trusted to carry them.
Event format¶
{
"id": "<SHA-256 of the serialized event, hex>",
"pubkey": "<author's public key, hex>",
"created_at": 1796118688,
"kind": 30500,
"tags": [["d", "my-model"], ["title", "My model"]],
"content": "",
"sig": "<BIP-340 signature of the id, hex>"
}
The id is the SHA-256 of the JSON array [0, pubkey, created_at, kind, tags, content], without extra white space. Identifiers can be written as did:nostr:<public key> where an author is expected.
Classes of events¶
| Kind | Class | Behavior |
|---|---|---|
| 0, 3, 10000 to 19999 | Replaceable | The newest event of an author and kind replaces the previous one |
| 20000 to 29999 | Ephemeral | Delivered to subscribers, not stored |
| 30000 to 39999 | Addressable | The newest event of an author, kind and d tag replaces the previous one |
| all others | Regular | Stored |
If two events have the same time, the one with the lower id wins. Every component applies the same rule, so all of them converge.
Deletion¶
A kind 5 event deletes events of its own author: by id with e tags, or by address with a tags (kind:pubkey:d). Deletions leave a tombstone, so a deleted event is refused when it arrives again.
Kinds used by the stack¶
| Kind | Meaning |
|---|---|
| 30500 | Asset: d name, title, summary, x SHA-256, cid, size, url, t labels |
| 30501 | Registry descriptor: name, endpoint, specialization, tags |
| 30502 | Binding of an operator key to a Hyperswarm node key |
| 22242 | Authentication |
| 5 | Deletion |
WebSocket protocol¶
A relay speaks NIP-01, with NIP-09 (deletion), NIP-11 (information document), NIP-13 (proof of work), NIP-42 (authentication) and NIP-77 (Negentropy synchronization).
| Client message | Purpose |
|---|---|
["EVENT", event] |
Publish. Answered by ["OK", id, accepted, message] |
["REQ", id, filter, ...] |
Query and subscribe. Up to 10 filters |
["CLOSE", id] |
End a subscription |
["AUTH", event] |
Answer the authentication challenge |
["NEG-OPEN", id, filter, message], ["NEG-MSG", id, message], ["NEG-CLOSE", id] |
Set reconciliation |
A filter has ids, authors, kinds, since, until, limit and #<letter> for tags. Stored events are returned newest first, followed by EOSE and then live events.
Refusals start with a reason: invalid:, blocked:, restricted:, pow:, rate-limited:, auth-required:, duplicate: or error:.
Limits¶
| Limit | Value |
|---|---|
| Message size | 1 MiB |
| Tag and content bytes of an event | 256 KiB |
| Tags per event | 2000, further limited by policy |
d tag |
1024 bytes |
| Subscriptions per connection | 20 |
| Events per stored query | 500 by default, at most 5000 |
| Negentropy sessions per connection | 4 |
| Events in one reconciliation | 1,000,000 |
| Connections per relay | 2000 |