Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIP-41: Poll & Vote Event #148

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions 41.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# NIP-41 - Poll & Vote Event

`draft` `optional` `author:0xtlt`

> Poll and vote events are a way to create a poll and vote for it.\
> Polls are directly integrated into message events (1), and responses are vote events (9) to avoid overloading the loading of messages in clients.

## Specs

### Kind `1` - Message & Poll

To create a poll, include a `poll` tag in the message event. with the following format:

```text
tag: poll
options:
- <multi|single> allow others to reply with one or multiple options
- <ttl> TTL (in seconds|timestamp) when surv expires, 0 TTL don't expire
- <title> optional poll name ("" if not present)
- [<option>]: array of string
```

#### Example - Message

```json
{
...
"kind": 1,
"tags": [
...
["poll", "single", "0", "I'm a title!", "Option 1", "Option 2", "Option 3"],
...
],
}
```

### Kind `9` - Vote

To vote for a poll, you have to send an event kind `9`.\
The format of the event is the following:

```text
kind: 9
content: <reason for voting> // Can be empty string
tag: poll_r // for poll response
options:
- [<choices>]: array of index of the option | the first option is 0
```

#### Example - Vote

```json
{
...
"kind": 9,
"tags": [
...
["e", "<event-id>"],
["poll_r", "0"],
// OR
["poll_r", "0", "2"]
...
],
"content": "reason for voting"
}
```

## Relay and client recommendations

- Options should be limited to 4 options and should not display more than **4 options** in the poll
- Each option should be 25 chars limited
- Clients should display poll options if more than **one option** is present in the poll
- Clients should ignore vote events if the poll is **expired**
- Clients should not display more than one poll per message. The first poll in the message should be displayed.
- Poll title should be displayed if present and should be limited to 25 chars

## Warning

Keep in mind that all votes are public and accessible to everyone.