mirror of
https://github.com/nostr-protocol/nips.git
synced 2025-12-10 00:58:51 +00:00
Compare commits
14 Commits
nip91
...
nostrband-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df577ccd11 | ||
|
|
cc3fbab153 | ||
|
|
3f11c00fb9 | ||
|
|
190122fd8d | ||
|
|
0782ebe0bc | ||
|
|
512caf7fcd | ||
|
|
6c62751e57 | ||
|
|
0e3d1cd5d8 | ||
|
|
5b6ca881e2 | ||
|
|
0f376a7aa4 | ||
|
|
d96f6f852a | ||
|
|
76fd221ff1 | ||
|
|
1f8bbbfb50 | ||
|
|
2561566af7 |
5
01.md
5
01.md
@@ -85,10 +85,11 @@ As a convention, all single-letter (only english alphabet letters: a-z, A-Z) key
|
|||||||
|
|
||||||
### Kinds
|
### Kinds
|
||||||
|
|
||||||
Kinds specify how clients should interpret the meaning of each event and the other fields of each event (e.g. an `"r"` tag may have a meaning in an event of kind 1 and an entirely different meaning in an event of kind 10002). Each NIP may define the meaning of a set of kinds that weren't defined elsewhere. This NIP defines two basic kinds:
|
Kinds specify how clients should interpret the meaning of each event and the other fields of each event (e.g. an `"r"` tag may have a meaning in an event of kind 1 and an entirely different meaning in an event of kind 10002). Each NIP may define the meaning of a set of kinds that weren't defined elsewhere. [NIP-10](10.md), for instance, especifies the `kind:1` text note for social media applications.
|
||||||
|
|
||||||
|
This NIP defines one basic kind:
|
||||||
|
|
||||||
- `0`: **user metadata**: the `content` is set to a stringified JSON object `{name: <username>, about: <string>, picture: <url, string>}` describing the user who created the event. [Extra metadata fields](24.md#kind-0) may be set. A relay may delete older events once it gets a new one for the same pubkey.
|
- `0`: **user metadata**: the `content` is set to a stringified JSON object `{name: <username>, about: <string>, picture: <url, string>}` describing the user who created the event. [Extra metadata fields](24.md#kind-0) may be set. A relay may delete older events once it gets a new one for the same pubkey.
|
||||||
- `1`: **text note**: the `content` is set to the **plaintext** content of a note (anything the user wants to say). Content that must be parsed, such as Markdown and HTML, should not be used. Clients should also not parse content as those.
|
|
||||||
|
|
||||||
And also a convention for kind ranges that allow for easier experimentation and flexibility of relay implementation:
|
And also a convention for kind ranges that allow for easier experimentation and flexibility of relay implementation:
|
||||||
|
|
||||||
|
|||||||
14
10.md
14
10.md
@@ -1,15 +1,23 @@
|
|||||||
NIP-10
|
NIP-10
|
||||||
======
|
======
|
||||||
|
|
||||||
|
Text Notes and Threads
|
||||||
On "e" and "p" tags in Text Events (kind 1)
|
----------------------
|
||||||
-------------------------------------------
|
|
||||||
|
|
||||||
`draft` `optional`
|
`draft` `optional`
|
||||||
|
|
||||||
|
This NIP defines `kind:1` as a simple plaintext note.
|
||||||
|
|
||||||
## Abstract
|
## Abstract
|
||||||
|
|
||||||
This NIP describes how to use "e" and "p" tags in text events, especially those that are replies to other text events. It helps clients thread the replies into a tree rooted at the original event.
|
This NIP describes how to use "e" and "p" tags in text events, especially those that are replies to other text events. It helps clients thread the replies into a tree rooted at the original event.
|
||||||
|
|
||||||
|
The `.content` property contains some human-readable text.
|
||||||
|
|
||||||
|
`e` and `p` tags can be used to define note threads, replies and mentions.
|
||||||
|
|
||||||
|
Markup languages such as markdown and HTML SHOULD NOT be used.
|
||||||
|
|
||||||
## Marked "e" tags (PREFERRED)
|
## Marked "e" tags (PREFERRED)
|
||||||
`["e", <event-id>, <relay-url>, <marker>, <pubkey>]`
|
`["e", <event-id>, <relay-url>, <marker>, <pubkey>]`
|
||||||
|
|
||||||
|
|||||||
2
18.md
2
18.md
@@ -10,6 +10,7 @@ A repost is a `kind 6` event that is used to signal to followers
|
|||||||
that a `kind 1` text note is worth reading.
|
that a `kind 1` text note is worth reading.
|
||||||
|
|
||||||
The `content` of a repost event is _the stringified JSON of the reposted note_. It MAY also be empty, but that is not recommended.
|
The `content` of a repost event is _the stringified JSON of the reposted note_. It MAY also be empty, but that is not recommended.
|
||||||
|
Reposts of [NIP-70](70.md)-protected events SHOULD always have an empty `content`.
|
||||||
|
|
||||||
The repost event MUST include an `e` tag with the `id` of the note that is
|
The repost event MUST include an `e` tag with the `id` of the note that is
|
||||||
being reposted. That tag MUST include a relay URL as its third entry
|
being reposted. That tag MUST include a relay URL as its third entry
|
||||||
@@ -41,3 +42,4 @@ as a "generic repost", that can include any kind of event inside other than
|
|||||||
|
|
||||||
`kind 16` reposts SHOULD contain a `k` tag with the stringified kind number
|
`kind 16` reposts SHOULD contain a `k` tag with the stringified kind number
|
||||||
of the reposted event as its value.
|
of the reposted event as its value.
|
||||||
|
|
||||||
|
|||||||
2
22.md
2
22.md
@@ -56,6 +56,8 @@ Their uppercase versions use the same type of values but relate to the root item
|
|||||||
|
|
||||||
`p` tags SHOULD be used when mentioning pubkeys in the `.content` with [NIP-21](21.md).
|
`p` tags SHOULD be used when mentioning pubkeys in the `.content` with [NIP-21](21.md).
|
||||||
|
|
||||||
|
Comments MUST NOT be used to reply to kind 1 notes. [NIP-10](10.md) should instead be followed.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
A comment on a blog post looks like this:
|
A comment on a blog post looks like this:
|
||||||
|
|||||||
9
28.md
9
28.md
@@ -52,10 +52,17 @@ Clients MAY add additional metadata fields.
|
|||||||
|
|
||||||
Clients SHOULD use [NIP-10](10.md) marked "e" tags to recommend a relay.
|
Clients SHOULD use [NIP-10](10.md) marked "e" tags to recommend a relay.
|
||||||
|
|
||||||
|
It is also possible to set the category name using the "t" tag. This category name can be searched and filtered.
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
"content": "{\"name\": \"Updated Demo Channel\", \"about\": \"Updating a test channel.\", \"picture\": \"https://placekitten.com/201/201\", \"relays\": [\"wss://nos.lol\", \"wss://nostr.mom\"]}",
|
"content": "{\"name\": \"Updated Demo Channel\", \"about\": \"Updating a test channel.\", \"picture\": \"https://placekitten.com/201/201\", \"relays\": [\"wss://nos.lol\", \"wss://nostr.mom\"]}",
|
||||||
"tags": [["e", <channel_create_event_id>, <relay-url>]],
|
"tags": [
|
||||||
|
["e", <channel_create_event_id>, <relay-url>, "root"],
|
||||||
|
["t", <category_name-1>],
|
||||||
|
["t", <category_name-2>],
|
||||||
|
["t", <category_name-3>],
|
||||||
|
],
|
||||||
// other fields...
|
// other fields...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
2
57.md
2
57.md
@@ -132,7 +132,7 @@ The following should be true of the `zap receipt` event:
|
|||||||
- `tags` MUST include the `p` tag (zap recipient) AND optional `e` tag from the `zap request` AND optional `a` tag from the `zap request` AND optional `P` tag from the pubkey of the zap request (zap sender).
|
- `tags` MUST include the `p` tag (zap recipient) AND optional `e` tag from the `zap request` AND optional `a` tag from the `zap request` AND optional `P` tag from the pubkey of the zap request (zap sender).
|
||||||
- The `zap receipt` MUST have a `bolt11` tag containing the description hash bolt11 invoice.
|
- The `zap receipt` MUST have a `bolt11` tag containing the description hash bolt11 invoice.
|
||||||
- The `zap receipt` MUST contain a `description` tag which is the JSON-encoded zap request.
|
- The `zap receipt` MUST contain a `description` tag which is the JSON-encoded zap request.
|
||||||
- `SHA256(description)` MUST match the description hash in the bolt11 invoice.
|
- `SHA256(description)` SHOULD match the description hash in the bolt11 invoice.
|
||||||
- The `zap receipt` MAY contain a `preimage` tag to match against the payment hash of the bolt11 invoice. This isn't really a payment proof, there is no real way to prove that the invoice is real or has been paid. You are trusting the author of the `zap receipt` for the legitimacy of the payment.
|
- The `zap receipt` MAY contain a `preimage` tag to match against the payment hash of the bolt11 invoice. This isn't really a payment proof, there is no real way to prove that the invoice is real or has been paid. You are trusting the author of the `zap receipt` for the legitimacy of the payment.
|
||||||
|
|
||||||
The `zap receipt` is not a proof of payment, all it proves is that some nostr user fetched an invoice. The existence of the `zap receipt` implies the invoice as paid, but it could be a lie given a rogue implementation.
|
The `zap receipt` is not a proof of payment, all it proves is that some nostr user fetched an invoice. The existence of the `zap receipt` implies the invoice as paid, but it could be a lie given a rogue implementation.
|
||||||
|
|||||||
2
59.md
2
59.md
@@ -53,7 +53,7 @@ without the receiver's or the sender's private key. The only public information
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Tags MUST must always be empty in a `kind:13`. The inner event MUST always be unsigned.
|
Tags MUST always be empty in a `kind:13`. The inner event MUST always be unsigned.
|
||||||
|
|
||||||
## 3. Gift Wrap Event Kind
|
## 3. Gift Wrap Event Kind
|
||||||
|
|
||||||
|
|||||||
2
60.md
2
60.md
@@ -54,7 +54,7 @@ Tags:
|
|||||||
Any tag, other than the `d` tag, can be [[NIP-44]] encrypted into the `.content` field.
|
Any tag, other than the `d` tag, can be [[NIP-44]] encrypted into the `.content` field.
|
||||||
|
|
||||||
### Deleting a wallet event
|
### Deleting a wallet event
|
||||||
Due to PRE being hard to delete, if a user wants to delete a wallet, they should empty the event and keep just the `d` identifier and add a `deleted` tag.
|
Due to addressable event being hard to delete, if a user wants to delete a wallet, they should empty the event and keep just the `d` identifier and add a `deleted` tag.
|
||||||
|
|
||||||
## Token Event
|
## Token Event
|
||||||
Token events are used to record the unspent proofs that come from the mint.
|
Token events are used to record the unspent proofs that come from the mint.
|
||||||
|
|||||||
2
61.md
2
61.md
@@ -70,7 +70,7 @@ WIP: Clients SHOULD embed a DLEQ proof in the nutzap event to make it possible t
|
|||||||
|
|
||||||
* The sender fetches the recipient's `kind:10019`.
|
* The sender fetches the recipient's `kind:10019`.
|
||||||
* The sender mints/swaps ecash on one of the recipient's listed mints.
|
* The sender mints/swaps ecash on one of the recipient's listed mints.
|
||||||
* The sender p2pk locks to the recipient's specified pubkey in their
|
* The sender p2pk locks to the recipient's specified pubkey in their `kind:10019`
|
||||||
|
|
||||||
# Receiving nutzaps
|
# Receiving nutzaps
|
||||||
|
|
||||||
|
|||||||
130
88.md
Normal file
130
88.md
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
# NIP-88
|
||||||
|
|
||||||
|
## Polls
|
||||||
|
|
||||||
|
`draft` `optional`
|
||||||
|
|
||||||
|
This NIP defines the event scheme that describe Polls on nostr.
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
### Poll Event
|
||||||
|
|
||||||
|
The poll event is defined as a `kind:1068` event.
|
||||||
|
|
||||||
|
- **content** key holds the label for the poll.
|
||||||
|
|
||||||
|
Major tags in the poll event are:
|
||||||
|
|
||||||
|
- **option**: The option tags contain an OptionId(any alphanumeric) field, followed by an option label field.
|
||||||
|
- **relay**: One or multiple tags that the poll is expecting respondents to respond on.
|
||||||
|
- **polltype**: can be "singlechoice" or "multiplechoice". Polls that do not have a polltype should be considered a "singlechoice" poll.
|
||||||
|
- **endsAt**: signifying at which unix timestamp the poll is meant to end.
|
||||||
|
|
||||||
|
Example Event
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"content": "Pineapple on pizza",
|
||||||
|
"created_at": 1719888496,
|
||||||
|
"id": "9d1b6b9562e66f2ecf35eb0a3c2decc736c47fddb13d6fb8f87185a153ea3634",
|
||||||
|
"kind": 1068,
|
||||||
|
"pubkey": "dee45a23c4f1d93f3a2043650c5081e4ac14a778e0acbef03de3768e4f81ac7b",
|
||||||
|
"sig": "7fa93bf3c430eaef784b0dacc217d3cd5eff1c520e7ef5d961381bc0f014dde6286618048d924808e54d1be03f2f2c2f0f8b5c9c2082a4480caf45a565ca9797",
|
||||||
|
"tags": [
|
||||||
|
["option", "qj518h583", "Yay"],
|
||||||
|
["option", "gga6cdnqj", "Nay"],
|
||||||
|
["relay", "<relay url1>"],
|
||||||
|
["relay", "<relay url2>"],
|
||||||
|
["polltype", "singlechoice"],
|
||||||
|
["endsAt", "<unix timestamp in seconds>"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Responses
|
||||||
|
|
||||||
|
The response event is a `kind:1018` event. It contains an e tag with the poll event it is referencing, followed by one or more response tags.
|
||||||
|
|
||||||
|
- **response** : The tag contains "response" as it's first positional argument followed by the option Id selected.
|
||||||
|
|
||||||
|
The responses are meant to be published to the relays specified in the poll event.
|
||||||
|
|
||||||
|
Example Response Event
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"content": "",
|
||||||
|
"created_at": 1720097117,
|
||||||
|
"id": "60a005e32e9596c3f544a841a9bc4e46d3020ca3650d6a739c95c1568e33f6d8",
|
||||||
|
"kind": 1018,
|
||||||
|
"pubkey": "1bc70a0148b3f316da33fe7e89f23e3e71ac4ff998027ec712b905cd24f6a411",
|
||||||
|
"sig": "30071a633c65db8f3a075c7a8de757fbd8ce65e3607f4ba287fe6d7fbf839a380f94ff4e826fbba593f6faaa13683b7ea9114ade140720ecf4927010ebf3e44f",
|
||||||
|
"tags": [
|
||||||
|
["e", "1fc80cf813f1af33d5a435862b7ef7fb96b47e68a48f1abcadf8081f5a545550"],
|
||||||
|
["response", "gga6cdnqj"],
|
||||||
|
["response", "m3agjsdq1"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Poll Types
|
||||||
|
|
||||||
|
The polltype setting dictates how multiple response tags are handled in the `kind:1018` event.
|
||||||
|
|
||||||
|
- **polltype: singlechoice**: The first response tag is to be considered the actual response.
|
||||||
|
- **polltype: multiplechoice**: The first response tag pointing to each id is considered the actual response, without considering the order of the response tags.
|
||||||
|
|
||||||
|
### Counting Results
|
||||||
|
|
||||||
|
Results can be queried by fetching `kind:1018` events from the relays specified in the poll.
|
||||||
|
The results displayed should only be 1 vote event per pubkey.
|
||||||
|
In case of multiple events for a pubkey, the event with the largest timestamp within the poll limits should be considered.
|
||||||
|
|
||||||
|
Example for querying polls.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const fetchVoteEvents = (filterPubkeys: string[]) => {
|
||||||
|
let resultFilter: Filter = {
|
||||||
|
"#e": [pollEvent.id],
|
||||||
|
kinds: [1018],
|
||||||
|
};
|
||||||
|
if (filterPubkeys?.length) {
|
||||||
|
resultFilter.authors = filterPubkeys;
|
||||||
|
}
|
||||||
|
if (pollExpiration) {
|
||||||
|
resultFilter.until = Number(pollExpiration);
|
||||||
|
}
|
||||||
|
pool.subscribeMany(relays, [resultFilter], {
|
||||||
|
onevent: handleResultEvent,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Example for maintaining OneVotePerPubkey
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const oneVotePerPubkey = (events: Event[]) => {
|
||||||
|
const eventMap = new Map<string, Event>();
|
||||||
|
|
||||||
|
events.forEach((event) => {
|
||||||
|
if (
|
||||||
|
!eventMap.has(event.pubkey) ||
|
||||||
|
event.created_at > eventMap.get(event.pubkey)!.created_at
|
||||||
|
) {
|
||||||
|
eventMap.set(event.pubkey, event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return Array.from(eventMap.values());
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Relays
|
||||||
|
|
||||||
|
It is advisable for poll authors to use relays that do not allow backdated events and do not honor kind:5 (delete) requests for vote events in order to maintain the integrity of poll results after the poll has ended.
|
||||||
|
|
||||||
|
### Curation
|
||||||
|
|
||||||
|
The clients may configure fetching results by specific people. This can be achieved by creating `kind:30000` follow sets, and fetching results only from the follow set.
|
||||||
|
Clients can also employ other curation algorithms, like Proof Of Work and Web of Trust scores for result curations.
|
||||||
@@ -31,7 +31,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
|||||||
- [NIP-07: `window.nostr` capability for web browsers](07.md)
|
- [NIP-07: `window.nostr` capability for web browsers](07.md)
|
||||||
- [NIP-08: Handling Mentions](08.md) --- **unrecommended**: deprecated in favor of [NIP-27](27.md)
|
- [NIP-08: Handling Mentions](08.md) --- **unrecommended**: deprecated in favor of [NIP-27](27.md)
|
||||||
- [NIP-09: Event Deletion Request](09.md)
|
- [NIP-09: Event Deletion Request](09.md)
|
||||||
- [NIP-10: Conventions for clients' use of `e` and `p` tags in text events](10.md)
|
- [NIP-10: Text Notes and Threads](10.md)
|
||||||
- [NIP-11: Relay Information Document](11.md)
|
- [NIP-11: Relay Information Document](11.md)
|
||||||
- [NIP-13: Proof of Work](13.md)
|
- [NIP-13: Proof of Work](13.md)
|
||||||
- [NIP-14: Subject tag in text events](14.md)
|
- [NIP-14: Subject tag in text events](14.md)
|
||||||
@@ -89,6 +89,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
|||||||
- [NIP-78: Application-specific data](78.md)
|
- [NIP-78: Application-specific data](78.md)
|
||||||
- [NIP-84: Highlights](84.md)
|
- [NIP-84: Highlights](84.md)
|
||||||
- [NIP-86: Relay Management API](86.md)
|
- [NIP-86: Relay Management API](86.md)
|
||||||
|
- [NIP-88: Polls](88.md)
|
||||||
- [NIP-89: Recommended Application Handlers](89.md)
|
- [NIP-89: Recommended Application Handlers](89.md)
|
||||||
- [NIP-90: Data Vending Machines](90.md)
|
- [NIP-90: Data Vending Machines](90.md)
|
||||||
- [NIP-92: Media Attachments](92.md)
|
- [NIP-92: Media Attachments](92.md)
|
||||||
@@ -104,7 +105,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
|||||||
| kind | description | NIP |
|
| kind | description | NIP |
|
||||||
| ------------- | ------------------------------- | -------------------------------------- |
|
| ------------- | ------------------------------- | -------------------------------------- |
|
||||||
| `0` | User Metadata | [01](01.md) |
|
| `0` | User Metadata | [01](01.md) |
|
||||||
| `1` | Short Text Note | [01](01.md) |
|
| `1` | Short Text Note | [10](10.md) |
|
||||||
| `2` | Recommend Relay | 01 (deprecated) |
|
| `2` | Recommend Relay | 01 (deprecated) |
|
||||||
| `3` | Follows | [02](02.md) |
|
| `3` | Follows | [02](02.md) |
|
||||||
| `4` | Encrypted Direct Messages | [04](04.md) |
|
| `4` | Encrypted Direct Messages | [04](04.md) |
|
||||||
@@ -128,11 +129,13 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
|||||||
| `44` | Channel Mute User | [28](28.md) |
|
| `44` | Channel Mute User | [28](28.md) |
|
||||||
| `64` | Chess (PGN) | [64](64.md) |
|
| `64` | Chess (PGN) | [64](64.md) |
|
||||||
| `818` | Merge Requests | [54](54.md) |
|
| `818` | Merge Requests | [54](54.md) |
|
||||||
|
| `1018` | Poll Response | [88](88.md) |
|
||||||
| `1021` | Bid | [15](15.md) |
|
| `1021` | Bid | [15](15.md) |
|
||||||
| `1022` | Bid confirmation | [15](15.md) |
|
| `1022` | Bid confirmation | [15](15.md) |
|
||||||
| `1040` | OpenTimestamps | [03](03.md) |
|
| `1040` | OpenTimestamps | [03](03.md) |
|
||||||
| `1059` | Gift Wrap | [59](59.md) |
|
| `1059` | Gift Wrap | [59](59.md) |
|
||||||
| `1063` | File Metadata | [94](94.md) |
|
| `1063` | File Metadata | [94](94.md) |
|
||||||
|
| `1068` | Poll | [88](88.md) |
|
||||||
| `1111` | Comment | [22](22.md) |
|
| `1111` | Comment | [22](22.md) |
|
||||||
| `1311` | Live Chat Message | [53](53.md) |
|
| `1311` | Live Chat Message | [53](53.md) |
|
||||||
| `1617` | Patches | [34](34.md) |
|
| `1617` | Patches | [34](34.md) |
|
||||||
@@ -206,6 +209,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
|||||||
| `30041` | Modular Article Content | [NKBIP-01] |
|
| `30041` | Modular Article Content | [NKBIP-01] |
|
||||||
| `30063` | Release artifact sets | [51](51.md) |
|
| `30063` | Release artifact sets | [51](51.md) |
|
||||||
| `30078` | Application-specific Data | [78](78.md) |
|
| `30078` | Application-specific Data | [78](78.md) |
|
||||||
|
| `30267` | App curation sets | [51](51.md) |
|
||||||
| `30311` | Live Event | [53](53.md) |
|
| `30311` | Live Event | [53](53.md) |
|
||||||
| `30315` | User Statuses | [38](38.md) |
|
| `30315` | User Statuses | [38](38.md) |
|
||||||
| `30388` | Slide Set | [Corny Chat][cornychat-slideset] |
|
| `30388` | Slide Set | [Corny Chat][cornychat-slideset] |
|
||||||
|
|||||||
Reference in New Issue
Block a user