nips/88.md

103 lines
4.2 KiB
Markdown
Raw Normal View History

2023-11-05 11:14:43 +00:00
NIP-88
======
Recurring Subscriptions
-----------------------
`draft` `optional` `author:pablof7z`
This NIP defines a way for a pubkey to create recurring subscription payments to another pubkey.
## Tier Event
A pubkey can create "tiers". These tiers might provide certain benefits to the supporters who subscribe to these.
```json
{
"kind": 37001,
2023-11-05 11:14:43 +00:00
"content": "<description of the tier>",
"tags": [
[ "title", "..." ],
[ "image", "..." ],
[ "amount", "<amount-in-base-unit>", "currency", "<monthly>" ],
[ "amount", "<amount-in-base-unit>", "currency", "<quarterly>" ]
2023-11-05 11:14:43 +00:00
]
}
```
This event is generated by a pubkey who wants to allow users to support with different tiers.
`.content` SHOULD be a description of what users who subscribe can expect.
Tag `title` is an optional title for the tier.
Tag `image` is an optional image for the tier.
2023-11-05 11:14:43 +00:00
Tag `amount` MUST specify the payment required for this tier and its cadence.
* The first argument should be the stringified amount and the second argument the currency
* The third argument SHOULD be one of `daily`, `monthly`, `yearly`
One or more `amount` tags MUST exist.
#### Examples
* `[ "amount", "100", "usd", "daily" ]`, $1.00 a day.
2023-11-23 15:23:49 +00:00
* `[ "amount", "1000000", "msats", "daily" ]`, 1000000 millisats a day.
2023-11-05 11:14:43 +00:00
## Subscribe Event
```json
{
"kind": 7001,
"content": "<optional-message>",
"tags": [
[ "p", "<recipient-pubkey>" ],
[ "a", "<supporting-tier-event-id>" ],
[ "event", "<stringied-event-subscribed-to>" ],
2023-11-05 11:14:43 +00:00
[ "amount", "<amount-in-base-unit>", "currency", "<cadence>" ]
]
}
```
When a user wants to subscribe to support a user they create a `kind:7001` event.
2023-11-05 11:14:43 +00:00
* `.content` is an optional message the supporter can write.
* The `p` tag MUST tag the pubkey being supported.
* The `a` tag is optional; it should point to a `kind:37001` support tier event. There MUST be exactly 0 or 1 `a` tag.
* The `event` tag is optional; subscribers can opt to keep the version of the event they subscribed to. There MUST be exactly 0 or 1 `event` tag.
* The `amount` tag specifies what the supporters is committing to pay to the supported pubkey and the candence. MUST be equal to one of the amounts specified in the `kind:37001` event. There MUST be exactly 1 `amount` tag.
2023-11-05 11:14:43 +00:00
The `kind:7001` event can be created without an `e` tag so that users can create recurring support events without the pubkey receiving the support having explicitly created a support tier.
## Paying
The supporting user should create a zap `p`-tagging the receiver and e-tagging the `kind:7001`. There MUST be a single `p` and a single `e` tag in the zap request.
2023-11-05 11:14:43 +00:00
```json
{
"kind": 9734,
"content": "",
"tags": [
[ "p", "<recipient-pubkey>" ],
[ "e", "<kind-7001-event-id>" ]
]
```
Clients supporting this NIP can check for zaps e-tagging the `kind:7001` event to find the pubkeys that have a valid, paid subscriptions at each different period.
The same `kind:7001` is re-zapped on a regular basis per the cadence specified in the event.
2023-11-23 15:30:42 +00:00
## Verifying Payment
The following conditions must be met to verify a payment:
* Time between zap receipts should be equal or less than the cadence specified in the `kind:7001` event.
* Amount of the zap receipt should be equal or greater than the amount specified in the `kind:7001` event. For currencies not directly supported by the zap spec, clients should do a best effort conversion to the currency specified in the `kind:7001` event at the time of zap receipt.
* Zap-receipts should include a zap request `e`-tagging the `kind:7001` event. Zap-receipts might not include a signature (for NWC-automated payments where the subscriber is not present to sign the zap request).
* Validations specified in [NIP-57](https://github.com/nostr-protocol/nips/blob/master/57.md).
2023-11-05 11:14:43 +00:00
## Stopping a subscription
A user who wants to signal they are no longer subscribed can publish a `kind:7002` event tagging the `kind:7001` they are stopping and `p`-tagging the pubkey they are no longer subscribed to.
```json
{
"kind": 7002,
"content": "<optional-message>",
"tags": [
[ "p", "<recipient-pubkey>" ],
[ "e", "<kind-7001-event-id>" ],
]
}
```