3.1 KiB
NIP-101 - Forms On Nostr
draft
optional
author:abhay-raizada
The nip provides a way for users to create form templates on nostr, and for other users to be able to fill them.
Form Template - Public
Event 30168
describes a form with field
tags that contain the description of each form field, with optional settings
{
"kind": 30168,
"content" : ""
"tags": [
["d", "<form identifier>"],
["name", "Name of the form"],
["settings", JSON.stringify({description: "<description of the form."})],
["field", "<fieldId>","<input-type>","<label for the field>","<Options (for option type)>", "<stringified JSON settings>"],
["field", "<fieldId>", "option", "label for options field",
JSON.stringify([["<optionId1>", "option label", "<optionId2>", "option label"]]),
"<stringified JSON settings>"})
]
],
"pubkey": "<Author of the form>"
}
The different tags used to describe the form are described as:
Tags | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d | The unique identifier of a form, for a user | ||||||||||||||||||
name | A text serving as the name of the form | ||||||||||||||||||
settings | An optional global config for the form. | ||||||||||||||||||
field | Contains the following values
|
Sharing and Private forms.
<TBD>
similar to the sharing of spreadsheets as described in the proposed NIP.
Responses - Public
Response events are attached to a form(3068 kind event), and the event data is stored in a kind: 30169
event
Response structure:
{
"kind": 30169,
"content" : "",
"tags": [["a", "30168:<pubkey of the author>:<form identifier>"],
["response", "<FieldId>", "<response as string>", "<stringified metadata object>"]],
"pubkey": "Author of Response"
}
for option fields, the response is the id of the option selected. In case of multiple-choice fields these id's maybe delimited by a semi-colon, ";", For example:
{
"kind": 30169,
"content" : "",
"tags": [["a", "30168:<pubkey of the author>:<form identifier>"],
["response", "<FieldId>", "ZCZC;XCZXCZ;Z34Z", "<stringified metadata object>"]],
"pubkey": "Response author"
}
Responses - Private
response tags are added to the ".content" field and encrypted as per the spec in nip-44