diff --git a/22.md b/22.md new file mode 100644 index 000000000..bdd3085db --- /dev/null +++ b/22.md @@ -0,0 +1,82 @@ +NIP-22 +====== + +Comment +------- + +`draft` `optional` + +A comment is meant to be used to comment on +or reply to anything except [NIP-01](01.md) `kind:1` events +and other event kinds whose specifications have already defined other +ways to comment on or reply to them. + +For example, it can be used to comment on a [NIP-23](23.md) `kind:30023` nostr blog post +or on an off-nostr news article or to reply to another comment. + +## Structure + +A comment is an event of `kind:1111` with plaintext `.content` +(no HTML, no Markdown nor other formatting). + +It must have a `k` tag pointing to the kind of the subject being commented on. +For example, when commenting on a `kind:30023`, the `k` tag is set to "30023". +When replying to another `kind:1111`, the `k` tag is set to "1111". +If commenting on an `https://abc.com/articles/1` artcile the `k` tag is set to "https://abc.com" (its domain). + +### Threads + +There is always an `o` tag pointing to the original post that started the thread. +It can be an event id (with an "i::" prefix), +an event address ("a:" prefix) or an url ("" prefix). The second value +is the optional recommended relay url where the referenced event may be found. +This tag is useful to load all messages of a thread at once. + +Note that if commenting on a replaceable event, one can choose to add both id and address references. + +Examples: + +- `["o", "i::", ""]` +- `["o", "a:", ""]` +- `["o", "https://abc.com/articles/1/"]` + +Also, there is always an `r` tag pointing to the subject being directly commented on or replied to, using the +same structure of the `o` tag. +This tag is useful to lazily load a thread. + +### Event Examples + +```js +{ + kind: 1111, + content: 'Agree with your comment.', + tags: [ + // referencing the OP + ["o", "https://abc.com/articles/1/"], + // replying to a parent kind:1111 comment + ["r", "i:f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca:5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"], + // the parent kind + ["k", "1111"] + ] + // other fields +} +``` + +```js +{ + kind: 1111, + content: 'Great blog post! Check this out nostr:npub1sn0wdenkukak0d9dfczzeacvhkrgz92ak56egt7vdgzn8pv2wfqqhrjdv9.', + tags: [ + // top-level comments have the same o and r tags + ["o", "a:30023:3c9849383bdea883b0bd16fece1ed36d37e37cdde3ce43b17ea4e9192ec11289:f9347ca7"], + ["r", "a:30023:3c9849383bdea883b0bd16fece1ed36d37e37cdde3ce43b17ea4e9192ec11289:f9347ca7"], + // the parent kind + ["k", "30023"], + // the nostr:npub1... mentioned on .content + ["p", "84dee6e676e5bb67b4ad4e042cf70cbd8681155db535942fcc6a0533858a7240"] + ] + // other fields +} +``` + +Note that ideally there are no `p` tags unless the pubkey is being mentioned on the `.content`.