diff options
| author | Vitor Pamplona <vitor@vitorpamplona.com> | 2024-12-19 10:15:46 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-19 10:15:46 -0500 |
| commit | f7d97f3f40dc6677e6f996ffff431142ffe05810 (patch) | |
| tree | 2eaa8c8628cc9a4b05811ed3869e21221fd85307 /22.md | |
| parent | d5b77b6d7348061cd0f16adc35e4d02a3a0b7380 (diff) | |
| parent | 561059ff85c171b87a12b8381b724b4afc569a97 (diff) | |
Merge branch 'master' into draft-event
Diffstat (limited to '22.md')
| -rw-r--r-- | 22.md | 184 |
1 files changed, 184 insertions, 0 deletions
| @@ -0,0 +1,184 @@ | |||
| 1 | NIP-22 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Comment | ||
| 5 | ------- | ||
| 6 | |||
| 7 | `draft` `optional` | ||
| 8 | |||
| 9 | A comment is a threading note always scoped to a root event or an `I`-tag. | ||
| 10 | |||
| 11 | It uses `kind:1111` with plaintext `.content` (no HTML, Markdown, or other formatting). | ||
| 12 | |||
| 13 | Comments MUST point to the root scope using uppercase tag names (e.g. `K`, `E`, `A` or `I`) | ||
| 14 | and MUST point to the parent item with lowercase ones (e.g. `k`, `e`, `a` or `i`). | ||
| 15 | |||
| 16 | ```jsonc | ||
| 17 | { | ||
| 18 | kind: 1111, | ||
| 19 | content: '<comment>', | ||
| 20 | tags: [ | ||
| 21 | // root scope: event addresses, event ids, or I-tags. | ||
| 22 | ["<A, E, I>", "<address, id or I-value>", "<relay or web page hint>", "<root event's pubkey, if an E tag>"], | ||
| 23 | // the root item kind | ||
| 24 | ["K", "<root kind>"], | ||
| 25 | |||
| 26 | // parent item: event addresses, event ids, or i-tags. | ||
| 27 | ["<a, e, i>", "<address, id or i-value>", "<relay or web page hint>", "<parent event's pubkey, if an e tag>"], | ||
| 28 | // parent item kind | ||
| 29 | ["k", "<parent comment kind>"] | ||
| 30 | ] | ||
| 31 | // other fields | ||
| 32 | } | ||
| 33 | ``` | ||
| 34 | |||
| 35 | Tags `K` and `k` MUST be present to define the event kind of the root and the parent items. | ||
| 36 | |||
| 37 | `I` and `i` tags create scopes for hashtags, geohashes, URLs, and other external identifiers. | ||
| 38 | |||
| 39 | The possible values for `i` tags – and `k` tags, when related to an extenal identity – are listed on [NIP-73](73.md). | ||
| 40 | Their uppercase versions use the same type of values but relate to the root item instead of the parent one. | ||
| 41 | |||
| 42 | `q` tags MAY be used when citing events in the `.content` with [NIP-21](21.md). | ||
| 43 | |||
| 44 | ```json | ||
| 45 | ["q", "<event-id> or <event-address>", "<relay-url>", "<pubkey-if-a-regular-event>"] | ||
| 46 | ``` | ||
| 47 | |||
| 48 | `p` tags SHOULD be used when mentioning pubkeys in the `.content` with [NIP-21](21.md). | ||
| 49 | If the parent item is an event, a `p` tag set to the parent event's author SHOULD be added. | ||
| 50 | |||
| 51 | ```json | ||
| 52 | ["p", "<pubkey>", "<relay-url>"] | ||
| 53 | ``` | ||
| 54 | |||
| 55 | ## Examples | ||
| 56 | |||
| 57 | A comment on a blog post looks like this: | ||
| 58 | |||
| 59 | ```jsonc | ||
| 60 | { | ||
| 61 | kind: 1111, | ||
| 62 | content: 'Great blog post!', | ||
| 63 | tags: [ | ||
| 64 | // top-level comments scope to event addresses or ids | ||
| 65 | ["A", "30023:3c9849383bdea883b0bd16fece1ed36d37e37cdde3ce43b17ea4e9192ec11289:f9347ca7", "wss://example.relay"], | ||
| 66 | // the root kind | ||
| 67 | ["K", "30023"], | ||
| 68 | |||
| 69 | // the parent event address (same as root for top-level comments) | ||
| 70 | ["a", "30023:3c9849383bdea883b0bd16fece1ed36d37e37cdde3ce43b17ea4e9192ec11289:f9347ca7", "wss://example.relay"], | ||
| 71 | // when the parent event is replaceable or addressable, also include an `e` tag referencing its id | ||
| 72 | ["e", "5b4fc7fed15672fefe65d2426f67197b71ccc82aa0cc8a9e94f683eb78e07651", "wss://example.relay"], | ||
| 73 | // the parent event kind | ||
| 74 | ["k", "30023"] | ||
| 75 | ] | ||
| 76 | // other fields | ||
| 77 | } | ||
| 78 | ``` | ||
| 79 | |||
| 80 | A comment on a [NIP-94](94.md) file looks like this: | ||
| 81 | |||
| 82 | ```jsonc | ||
| 83 | { | ||
| 84 | kind: 1111, | ||
| 85 | content: 'Great file!', | ||
| 86 | tags: [ | ||
| 87 | // top-level comments have the same scope and reply to addresses or ids | ||
| 88 | ["E", "768ac8720cdeb59227cf95e98b66560ef03d8bc9a90d721779e76e68fb42f5e6", "wss://example.relay", "3721e07b079525289877c366ccab47112bdff3d1b44758ca333feb2dbbbbe5bb"], | ||
| 89 | // the root kind | ||
| 90 | ["K", "1063"], | ||
| 91 | |||
| 92 | // the parent event id (same as root for top-level comments) | ||
| 93 | ["e", "768ac8720cdeb59227cf95e98b66560ef03d8bc9a90d721779e76e68fb42f5e6", "wss://example.relay", "3721e07b079525289877c366ccab47112bdff3d1b44758ca333feb2dbbbbe5bb"], | ||
| 94 | // the parent kind | ||
| 95 | ["k", "1063"] | ||
| 96 | ] | ||
| 97 | // other fields | ||
| 98 | } | ||
| 99 | ``` | ||
| 100 | |||
| 101 | A reply to a comment looks like this: | ||
| 102 | |||
| 103 | ```jsonc | ||
| 104 | { | ||
| 105 | kind: 1111, | ||
| 106 | content: 'This is a reply to "Great file!"', | ||
| 107 | tags: [ | ||
| 108 | // nip-94 file event id | ||
| 109 | ["E", "768ac8720cdeb59227cf95e98b66560ef03d8bc9a90d721779e76e68fb42f5e6", "wss://example.relay", "fd913cd6fa9edb8405750cd02a8bbe16e158b8676c0e69fdc27436cc4a54cc9a"], | ||
| 110 | // the root kind | ||
| 111 | ["K", "1063"], | ||
| 112 | |||
| 113 | // the parent event | ||
| 114 | ["e", "5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36", "wss://example.relay", "93ef2ebaaf9554661f33e79949007900bbc535d239a4c801c33a4d67d3e7f546"], | ||
| 115 | // the parent kind | ||
| 116 | ["k", "1111"] | ||
| 117 | ] | ||
| 118 | // other fields | ||
| 119 | } | ||
| 120 | ``` | ||
| 121 | |||
| 122 | A comment on a website's url looks like this: | ||
| 123 | |||
| 124 | ```jsonc | ||
| 125 | { | ||
| 126 | kind: 1111, | ||
| 127 | content: 'Nice article!', | ||
| 128 | tags: [ | ||
| 129 | // referencing the root url | ||
| 130 | ["I", "https://abc.com/articles/1"], | ||
| 131 | // the root "kind": for an url, the kind is its domain | ||
| 132 | ["K", "https://abc.com"], | ||
| 133 | |||
| 134 | // the parent reference (same as root for top-level comments) | ||
| 135 | ["i", "https://abc.com/articles/1"], | ||
| 136 | // the parent "kind": for an url, the kind is its domain | ||
| 137 | ["k", "https://abc.com"] | ||
| 138 | ] | ||
| 139 | // other fields | ||
| 140 | } | ||
| 141 | ``` | ||
| 142 | |||
| 143 | A podcast comment example: | ||
| 144 | |||
| 145 | ```jsonc | ||
| 146 | { | ||
| 147 | id: "80c48d992a38f9c445b943a9c9f1010b396676013443765750431a9004bdac05", | ||
| 148 | pubkey: "252f10c83610ebca1a059c0bae8255eba2f95be4d1d7bcfa89d7248a82d9f111", | ||
| 149 | kind: 1111, | ||
| 150 | content: "This was a great episode!", | ||
| 151 | tags: [ | ||
| 152 | // podcast episode reference | ||
| 153 | ["I", "podcast:item:guid:d98d189b-dc7b-45b1-8720-d4b98690f31f", "https://fountain.fm/episode/z1y9TMQRuqXl2awyrQxg"], | ||
| 154 | // podcast episode type | ||
| 155 | ["K", "podcast:item:guid"], | ||
| 156 | |||
| 157 | // same value as "I" tag above, because it is a top-level comment (not a reply to a comment) | ||
| 158 | ["i", "podcast:item:guid:d98d189b-dc7b-45b1-8720-d4b98690f31f", "https://fountain.fm/episode/z1y9TMQRuqXl2awyrQxg"], | ||
| 159 | ["k", "podcast:item:guid"] | ||
| 160 | ] | ||
| 161 | // other fields | ||
| 162 | } | ||
| 163 | ``` | ||
| 164 | |||
| 165 | A reply to a podcast comment: | ||
| 166 | |||
| 167 | ```jsonc | ||
| 168 | { | ||
| 169 | kind: 1111, | ||
| 170 | content: "I'm replying to the above comment.", | ||
| 171 | tags: [ | ||
| 172 | // podcast episode reference | ||
| 173 | ["I", "podcast:item:guid:d98d189b-dc7b-45b1-8720-d4b98690f31f", "https://fountain.fm/episode/z1y9TMQRuqXl2awyrQxg"], | ||
| 174 | // podcast episode type | ||
| 175 | ["K", "podcast:item:guid"], | ||
| 176 | |||
| 177 | // this is a reference to the above comment | ||
| 178 | ["e", "80c48d992a38f9c445b943a9c9f1010b396676013443765750431a9004bdac05", "wss://example.relay", "252f10c83610ebca1a059c0bae8255eba2f95be4d1d7bcfa89d7248a82d9f111"], | ||
| 179 | // the parent comment kind | ||
| 180 | ["k", "1111"] | ||
| 181 | ] | ||
| 182 | // other fields | ||
| 183 | } | ||
| 184 | ``` | ||