diff options
| author | Pablo Fernandez <p@f7z.io> | 2024-02-11 17:05:39 +0000 |
|---|---|---|
| committer | Pablo Fernandez <p@f7z.io> | 2024-02-11 17:05:39 +0000 |
| commit | 00691c5f037060c1a51c1465ca5ce4ca4bbaf859 (patch) | |
| tree | 68d7a7bbe35eb2d55f15e12270b066e0fb707e28 | |
| parent | ab435386971ab17dd4aeef047e4acda8b366c7b1 (diff) | |
payment verification, relay where content can be found, perks, actor definitions
| -rw-r--r-- | 88.md | 94 |
1 files changed, 72 insertions, 22 deletions
| @@ -8,8 +8,19 @@ Recurring Subscriptions | |||
| 8 | 8 | ||
| 9 | This NIP defines a way for a pubkey to create recurring subscription payments to another pubkey. | 9 | This NIP defines a way for a pubkey to create recurring subscription payments to another pubkey. |
| 10 | 10 | ||
| 11 | ## Tier Event | 11 | Actors in this flow: |
| 12 | A pubkey can create "tiers". These tiers might provide certain benefits to the supporters who subscribe to these. | 12 | * Recipient: A pubkey that receives recurring payments |
| 13 | * Subscriber: A pubkey that sends recurring payments | ||
| 14 | * Payment verifier: An optional pubkey recipients can designate to verify payments on their behalf | ||
| 15 | |||
| 16 | # Kinds | ||
| 17 | `kind:37001` - Tier Event -- Optionally published by recipients | ||
| 18 | `kind:7001` - Subscribe Event -- Published by subscribers | ||
| 19 | `kind:7002` - Unsubscribe Event -- Published by subscribers | ||
| 20 | `kind:7003` - Subscription Payment Receipt -- Published by payment-verifier-pubkey | ||
| 21 | |||
| 22 | ## `kind:37001`: Tier Event | ||
| 23 | A pubkey that wants to provide others the ability to subscribe to them can create "tiers". These tiers might provide certain benefits to the supporters who subscribe to these. | ||
| 13 | 24 | ||
| 14 | ```js | 25 | ```js |
| 15 | { | 26 | { |
| @@ -18,34 +29,49 @@ A pubkey can create "tiers". These tiers might provide certain benefits to the s | |||
| 18 | "tags": [ | 29 | "tags": [ |
| 19 | [ "title", "..." ], | 30 | [ "title", "..." ], |
| 20 | [ "image", "..." ], | 31 | [ "image", "..." ], |
| 32 | |||
| 33 | // Perks | ||
| 34 | [ "perk", "<description>" ], | ||
| 35 | [ "perk", "<description>" ], | ||
| 36 | |||
| 37 | // Amount possibilities | ||
| 21 | [ "amount", "<amount-in-base-unit>", "currency", "<monthly>" ], | 38 | [ "amount", "<amount-in-base-unit>", "currency", "<monthly>" ], |
| 22 | [ "amount", "<amount-in-base-unit>", "currency", "<quarterly>" ], | 39 | [ "amount", "<amount-in-base-unit>", "currency", "<quarterly>" ], |
| 40 | |||
| 41 | // Zap-splits | ||
| 23 | [ "zap", "<recipient-pubkey>", "relay-url", "19" ], // 95% | 42 | [ "zap", "<recipient-pubkey>", "relay-url", "19" ], // 95% |
| 24 | [ "zap", "", "relay-url", "1" ], // 5% | 43 | [ "zap", "", "relay-url", "1" ], // 5% |
| 44 | |||
| 45 | // Relay and payment-verification | ||
| 46 | [ "r", "wss://my-subscribers-only-relay.com" ], | ||
| 47 | [ "p", "<payment-verifier-pubkey>" ], | ||
| 25 | ] | 48 | ] |
| 26 | } | 49 | } |
| 27 | ``` | 50 | ``` |
| 28 | 51 | ||
| 29 | This event is generated by a pubkey who wants to allow users to support with different tiers. | 52 | `.content`: description of what subscribers can expect. |
| 30 | |||
| 31 | `.content` SHOULD be a description of what users who subscribe can expect. | ||
| 32 | Tag `title` is an optional title for the tier. | 53 | Tag `title` is an optional title for the tier. |
| 33 | Tag `image` is an optional image for the tier. | 54 | Tag `image` is an optional image for the tier. |
| 34 | Tag `amount` MUST specify the payment required for this tier and its cadence. | 55 | Zero or more `perk` tags specify the benefits of the tier; these can be rendered as a list of benefits to the user in addition to the content. |
| 35 | * The first argument should be the stringified amount and the second argument the currency | 56 | One or more `amount` tags specify the payment required for this tier and its cadence. |
| 57 | * The first argument should be the stringified amount in cents or msats, and the second argument the currency | ||
| 36 | * The third argument SHOULD be one of `daily`, `monthly`, `yearly` | 58 | * The third argument SHOULD be one of `daily`, `monthly`, `yearly` |
| 37 | One or more `amount` tags MUST exist. | 59 | One or more `amount` tags MUST exist. |
| 38 | Zero or more `zap` tags can exist as defined in NIP-57. | 60 | Zero or more `zap` tags can exist as defined in NIP-57. |
| 39 | 61 | ||
| 40 | A `zap` tag with no pubkey indicates that the client can include any pubkey in the `kind:7001` event (and in the resulting recurring zaps). This way, users can offer a "referral" fee to other clients. | 62 | A `zap` tag with no pubkey indicates that the client can include any pubkey in the `kind:7001` event (and in the resulting recurring zaps). This way, users can offer a "referral" fee to other clients. |
| 41 | 63 | ||
| 64 | An `r` tag can be included to specify a relay where clients can find special content for this tier. | ||
| 65 | |||
| 66 | Zero or more `p` tags can be included to specify a pubkey that is trusted by the tier creator to verify payments on their behalf. | ||
| 67 | |||
| 42 | #### Examples | 68 | #### Examples |
| 43 | * `[ "amount", "100", "usd", "daily" ]`, $1.00 a day. | 69 | * `[ "amount", "100", "usd", "daily" ]`, $1.00 a day. |
| 44 | * `[ "amount", "1000000", "msats", "daily" ]`, 1000000 millisats a day. | 70 | * `[ "amount", "1000000", "msats", "daily" ]`, 1000000 millisats a day. |
| 45 | 71 | ||
| 46 | ## Subscribe Event | 72 | ## Subscribe Event |
| 47 | 73 | ||
| 48 | ```json | 74 | ```js |
| 49 | { | 75 | { |
| 50 | "kind": 7001, | 76 | "kind": 7001, |
| 51 | "content": "<optional-message>", | 77 | "content": "<optional-message>", |
| @@ -54,11 +80,10 @@ A `zap` tag with no pubkey indicates that the client can include any pubkey in t | |||
| 54 | [ "a", "<supporting-tier-event-id>" ], | 80 | [ "a", "<supporting-tier-event-id>" ], |
| 55 | [ "event", "<stringied-event-subscribed-to>" ], | 81 | [ "event", "<stringied-event-subscribed-to>" ], |
| 56 | [ "amount", "<amount-in-base-unit>", "<currency>", "<cadence>" ], | 82 | [ "amount", "<amount-in-base-unit>", "<currency>", "<cadence>" ], |
| 83 | |||
| 84 | // Zap-splits | ||
| 57 | [ "zap", "<recipient-pubkey>", "19" ], // 95% | 85 | [ "zap", "<recipient-pubkey>", "19" ], // 95% |
| 58 | [ "zap", "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52", "1" ], // 5% to client developer where subscription was created | 86 | [ "zap", "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52", "1" ], // 5% to client developer where subscription was created |
| 59 | [ "alt", "This is a subscription event" ], | ||
| 60 | [ "client", "highlighter", "31990:73c6bb92440a9344279f7a36aa3de1710c9198b1e9e8a394cd13e0dd5c994c63:1704502265408" ], | ||
| 61 | |||
| 62 | ] | 87 | ] |
| 63 | } | 88 | } |
| 64 | ``` | 89 | ``` |
| @@ -80,7 +105,7 @@ The `kind:7001` event can be created without an `e` tag so that users can create | |||
| 80 | ## Paying | 105 | ## Paying |
| 81 | 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. | 106 | 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. |
| 82 | 107 | ||
| 83 | ```json | 108 | ```js |
| 84 | { | 109 | { |
| 85 | "kind": 9734, | 110 | "kind": 9734, |
| 86 | "content": "", | 111 | "content": "", |
| @@ -94,18 +119,10 @@ Clients supporting this NIP can check for zaps e-tagging the `kind:7001` event t | |||
| 94 | 119 | ||
| 95 | The same `kind:7001` is re-zapped on a regular basis per the cadence specified in the event. | 120 | The same `kind:7001` is re-zapped on a regular basis per the cadence specified in the event. |
| 96 | 121 | ||
| 97 | ## Verifying Payment | ||
| 98 | The following conditions must be met to verify a payment: | ||
| 99 | |||
| 100 | * Time between zap receipts should be equal or less than the cadence specified in the `kind:7001` event. | ||
| 101 | * 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. | ||
| 102 | * 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). | ||
| 103 | * Validations specified in [NIP-57](https://github.com/nostr-protocol/nips/blob/master/57.md). | ||
| 104 | |||
| 105 | ## Stopping a subscription | 122 | ## Stopping a subscription |
| 106 | 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. | 123 | 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. |
| 107 | 124 | ||
| 108 | ```json | 125 | ```js |
| 109 | { | 126 | { |
| 110 | "kind": 7002, | 127 | "kind": 7002, |
| 111 | "content": "<optional-message>", | 128 | "content": "<optional-message>", |
| @@ -114,4 +131,37 @@ A user who wants to signal they are no longer subscribed can publish a `kind:700 | |||
| 114 | [ "e", "<kind-7001-event-id>" ], | 131 | [ "e", "<kind-7001-event-id>" ], |
| 115 | ] | 132 | ] |
| 116 | } | 133 | } |
| 117 | ``` \ No newline at end of file | 134 | ``` |
| 135 | |||
| 136 | ## Subscription Payment Receipt | ||
| 137 | When a subscription payment is made and a `payment-verifier-pubkey` is set on the `kind:37001` this pubkey publishes `kind:7003` events tagging the `kind:7001` event that was paid and `p`-tagging the pubkey that received the payment. | ||
| 138 | |||
| 139 | ```js | ||
| 140 | { | ||
| 141 | "kind": 7003, | ||
| 142 | "content": "<optional-message>", | ||
| 143 | "tags": [ | ||
| 144 | [ "p", "<recipient-pubkey>" ], | ||
| 145 | [ "P", "<subscriber-pubkey>" ], | ||
| 146 | [ "e", "<kind-7001-event-id>" ], | ||
| 147 | [ "valid", "<from-timestamp>", "<to-timestamp>" ] | ||
| 148 | [ "tier", "kind:37001-d-tag" ] | ||
| 149 | ] | ||
| 150 | } | ||
| 151 | ``` | ||
| 152 | |||
| 153 | `p` is the pubkey that received the payment. | ||
| 154 | `P` is the pubkey that made the payment. | ||
| 155 | `e` is the `kind:7001` event that was paid. | ||
| 156 | `valid` is the period for which the payment is valid. | ||
| 157 | `tier` is the d-tag of the `kind:37001` that this subscription is for. | ||
| 158 | |||
| 159 | # Appendix 0: Verifying Payment | ||
| 160 | The following conditions must be met to verify a payment: | ||
| 161 | |||
| 162 | * Time between zap receipts should be equal or less than the cadence specified in the `kind:7001` event. | ||
| 163 | * 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. | ||
| 164 | * 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). | ||
| 165 | * Validations specified in [NIP-57](https://github.com/nostr-protocol/nips/blob/master/57.md). | ||
| 166 | |||
| 167 | If `kind:7003` events are published by the payment-verifier-pubkey, clients can use these to verify payments more simply. \ No newline at end of file | ||