Chapter 20 - Core
20
Nostr Implementation Possibility - Hex № 20

Command Results

This chapter is closed. NIP-20 once defined the OK message. That rule is now part of the core protocol in NIP-01.

Merged

1 Overview

Before NIP-20, a client that published an event had no reliable way to know if a relay accepted it. A relay could only send a free-text NOTICE message, which no program could parse with confidence.

NIP-20 fixed this with a new message type, OK. A relay sends exactly one OK for every EVENT command it receives, well-formed or not. The message carries a machine-readable status: true or false, plus a prefixed reason string.

Merged

NIP-20 is closed and carries no separate rules of its own anymore. The OK message and its status prefixes now live in NIP-01, section 5 (Client ↔ Relay Messages). Read this page for history, then read NIP-01 for the current spec.

2 What NIP-20 Defined

NIP-20 stated these rules, restated here in Simplified Technical English:

Wire format - OK message, as originally defined
["OK", <event_id>, <true|false>, <message>]
  • The relay must send true when it saved the event, including when the event was already a duplicate.
  • The relay must send false when it rejected the event and did not save it.
  • The relay must not send OK for ephemeral events unless something failed.
  • If the EVENT command itself is malformed and cannot be parsed, the relay sends NOTICE instead of OK.

NIP-20 defined the message prefix convention: a single lower-case word, then a colon, then a human-readable reason. It defined five prefixes:

NIP-20 status prefixes, as originally defined
PrefixMeaning
duplicateThe event was already saved.
blockedThe pubkey or network address is blocked or not on a whitelist.
invalidThe event fails validation, for example a bad signature or an out-of-range timestamp.
powThe event does not meet the relay's required proof-of-work difficulty.
rate-limitedThe client is sending events too fast.
errorAnything else, such as a server-side failure.

Where It Lives Now

NIP-01 kept the OK message and every original prefix. It added two more: restricted, for a client that is not allowed to write, and mute, for an ephemeral event nobody was listening for. NIP-01 also added a related message type, CLOSED, which reports subscription-level failures using the same prefix convention. CLOSED did not come from NIP-20; it was added directly to NIP-01 later.

3 Historical Example

These are examples from the original NIP-20 text. They still match the wire format under NIP-01 today.

Examples - from the original NIP-20 text
← ["OK", "b1a649ebe8…", true, ""]
-- accepted, with a reason --
← ["OK", "b1a649ebe8…", true, "pow: difficulty 25>=24"]
-- rejected: banned pubkey --
← ["OK", "b1a649ebe8…", false, "blocked: you are banned from posting here"]
-- rejected: rate limited --
← ["OK", "b1a649ebe8…", false, "rate-limited: slow down there chief"]
-- rejected: bad timestamp --
← ["OK", "b1a649ebe8…", false, "invalid: event creation date is too far off from the current time. Is your system clock in sync?"]

4 Version History

  • Closed2023-08-13Merged into NIP-01 along with NIP-12, NIP-16, and NIP-33 (PR #703). All four were already "final, mandatory" — folding them into the root spec meant a client or relay only had to read one document to reach baseline compliance.
  • 20232023-11-15Repo-wide cleanup removed the per-file author badge from the now-stub page.
  • 20232023-03-02ennmichael fixed a typo.
  • 20222022-12-16sgmoore made minor grammar fixes.
  • Origin2022-11-10William Casarin (jb55) published NIP-20 and, the same day, added the invalid and pow prefixes, clarified malformed-versus-invalid handling, and noted that server errors need their own prefix too.

Original Proposal - Credits

AuthorWilliam Casarin (jb55)
First commit2022-11-10 — “NIP-20: Command Results”
Statusfinal mandatory — merged, no longer a standalone document
Source20.md on GitHub - full change history

5 See Also

  • NIP-01 — the current, canonical home of the OK message and its status prefixes.
  • NIP-12 — generic tag queries, merged the same day as NIP-20.
  • NIP-16 — event treatment, merged the same day as NIP-20.
  • NIP-13 — proof of work, referenced by the pow status prefix.