diff --git a/41.md b/41.md new file mode 100644 index 0000000000..8fb057ca6f --- /dev/null +++ b/41.md @@ -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: + - allow others to reply with one or multiple options + - TTL (in seconds|timestamp) when surv expires, 0 TTL don't expire + - 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.