mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-12 15:09:07 -05:00
1.9 KiB
1.9 KiB
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:
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
{
...
"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:
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
{
...
"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.