nips/25.md

91 lines
3.6 KiB
Markdown
Raw Normal View History

NIP-25
======
Reactions
---------
2023-11-15 19:42:51 -05:00
`draft` `optional`
A reaction is a `kind 7` event that is used to react to other events.
The generic reaction, represented by the `content` set to a `+` string, SHOULD
be interpreted as a "like" or "upvote".
2023-01-01 02:15:08 -05:00
A reaction with `content` set to `-` SHOULD be interpreted as a "dislike" or
"downvote". It SHOULD NOT be counted as a "like", and MAY be displayed as a
downvote or dislike on a post. A client MAY also choose to tally likes against
dislikes in a reddit-like system of upvotes and downvotes, or display them as
2023-04-07 08:08:03 -04:00
separate tallies.
The `content` MAY be an emoji, or [NIP-30](30.md) custom emoji in this case it MAY be interpreted as a "like" or "dislike",
2023-08-10 16:48:53 -04:00
or the client MAY display this emoji reaction on the post. If the `content` is an empty string then the client should
consider it a "+".
Tags
----
2024-05-04 16:35:39 -04:00
The reaction event SHOULD include `a`, `e` and `p` tags pointing to the note the user is
2024-05-04 16:10:13 -04:00
reacting to. The `p` tag allows authors to be notified. The `e` tags enables clients
2024-05-04 16:35:39 -04:00
to pull all the reactions to individual events and `a` tags enables clients to seek reactions
for all versions of a replaceable event.
2024-05-04 16:10:13 -04:00
The `e` tag MUST be the `id` of the note that is being reacted to.
2024-05-04 16:35:39 -04:00
The `a` tag MUST contain the coordinates (`kind:pubkey:d-tag`) of the replaceable being reacted to.
2024-05-04 16:10:13 -04:00
The `p` tag MUST be the `pubkey` of the event being reacted to.
The reaction event MAY include a `k` tag with the stringified kind number
of the reacted event as its value.
Example code
```swift
func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent {
tags.append(["e", liked.id])
tags.append(["p", liked.pubkey])
tags.append(["k", liked.kind])
let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags)
ev.calculate_id()
ev.sign(privkey: privkey)
return ev
}
2023-07-10 11:15:34 -04:00
```
Custom Emoji Reaction
---------------------
2023-07-13 20:08:03 -04:00
The client may specify a custom emoji ([NIP-30](30.md)) `:shortcode:` in the
2023-07-10 11:15:34 -04:00
reaction content. The client should refer to the emoji tag and render the
content as an emoji if shortcode is specified.
```json
{
"kind": 7,
"content": ":soapbox:",
"tags": [
["emoji", "soapbox", "https://gleasonator.com/emoji/Gleasonator/soapbox.png"]
],
"pubkey": "79c2cae114ea28a981e7559b4fe7854a473521a8d22a66bbab9fa248eb820ff6",
"created_at": 1682790000
}
```
The content can be set only one `:shortcode:`. And emoji tag should be one.
2024-05-28 06:16:04 -04:00
Cashu Ecash Reaction
---------------------
The client may also specify a Cashu Ecash token `cashu***` in the reaction content. This Ecash token should utilize P2PK ([NUT-11](https://github.com/cashubtc/nuts/blob/main/11.md)) and lock the token to the `pubkey` associated with the event being reacted to. Upon receiving the reaction content, the client is required to validate the DLEQ proof ([NUT-12](https://github.com/cashubtc/nuts/blob/main/12.md)).
```json
{
"kind": 7,
"content": "cashuAeyJ0b2tlbiI6W3sibWludCI6Imh0dHBzOi8vODMzMy5zcGFjZTozMzM4IiwicHJvb2ZzIjpbeyJhbW91bnQiOjIsImlkIjoiMDA5YTFmMjkzMjUzZTQxZSIsInNlY3JldCI6IjQwNzkxNWJjMjEyYmU2MWE3N2UzZTZkMmFlYjRjNzI3OTgwYmRhNTFjZDA2YTZhZmMyOWUyODYxNzY4YTc4MzciLCJDIjoiMDJiYzkwOTc5OTdkODFhZmIyY2M3MzQ2YjVlNDM0NWE5MzQ2YmQyYTUwNmViNzk1ODU5OGE3MmYwY2Y4NTE2M2VhIn0seyJhbW91bnQiOjgsImlkIjoiMDA5YTFmMjkzMjUzZTQxZSIsInNlY3JldCI6ImZlMTUxMDkzMTRlNjFkNzc1NmIwZjhlZTBmMjNhNjI0YWNhYTNmNGUwNDJmNjE0MzNjNzI4YzcwNTdiOTMxYmUiLCJDIjoiMDI5ZThlNTA1MGI4OTBhN2Q2YzA5NjhkYjE2YmMxZDVkNWZhMDQwZWExZGUyODRmNmVjNjlkNjEyOTlmNjcxMDU5In1dfV0sInVuaXQiOiJzYXQiLCJtZW1vIjoiVGhhbmsgeW91LiJ9",
"pubkey": "79c2cae114ea28a981e7559b4fe7854a473521a8d22a66bbab9fa248eb820ff6",
"created_at": 1682790000
}
```