mirror of
https://github.com/nostr-protocol/nips.git
synced 2025-12-09 08:38:50 +00:00
reformat a bunch of json things and small nitpicks.
This commit is contained in:
205
15.md
205
15.md
@@ -1,14 +1,14 @@
|
||||
NIP-15
|
||||
======
|
||||
|
||||
Nostr Marketplace (for resilient marketplaces)
|
||||
-----------------------------------
|
||||
Nostr Marketplace
|
||||
-----------------
|
||||
|
||||
`draft` `optional`
|
||||
`draft` `optional`
|
||||
|
||||
> Based on https://github.com/lnbits/Diagon-Alley
|
||||
Based on https://github.com/lnbits/Diagon-Alley.
|
||||
|
||||
> Implemented in [NostrMarket](https://github.com/lnbits/nostrmarket) and [Plebeian Market](https://github.com/PlebeianTech/plebeian-market)
|
||||
Implemented in [NostrMarket](https://github.com/lnbits/nostrmarket) and [Plebeian Market](https://github.com/PlebeianTech/plebeian-market).
|
||||
|
||||
## Terms
|
||||
|
||||
@@ -35,29 +35,30 @@ The `merchant` admin software can be purely clientside, but for `convenience` an
|
||||
A merchant can publish these events:
|
||||
| Kind | | Description |
|
||||
| --------- | ------------------ | --------------------------------------------------------------------------------------------------------------- |
|
||||
| `0 ` | `set_meta` | The merchant description (similar with any `nostr` public key). |
|
||||
| `0` | `set_meta` | The merchant description (similar with any `nostr` public key). |
|
||||
| `30017` | `set_stall` | Create or update a stall. |
|
||||
| `30018` | `set_product` | Create or update a product. |
|
||||
| `4 ` | `direct_message` | Communicate with the customer. The messages can be plain-text or JSON. |
|
||||
| `5 ` | `delete` | Delete a product or a stall. |
|
||||
| `4` | `direct_message` | Communicate with the customer. The messages can be plain-text or JSON. |
|
||||
| `5` | `delete` | Delete a product or a stall. |
|
||||
|
||||
### Event `30017`: Create or update a stall.
|
||||
|
||||
**Event Content**:
|
||||
**Event Content**
|
||||
|
||||
```json
|
||||
{
|
||||
"id": <String, UUID generated by the merchant. Sequential IDs (`0`, `1`, `2`...) are discouraged>,
|
||||
"name": <String, stall name>,
|
||||
"description": <String (optional), stall description>,
|
||||
"currency": <String, currency used>,
|
||||
"shipping": [
|
||||
{
|
||||
"id": <String, UUID of the shipping zone, generated by the merchant>,
|
||||
"name": <String (optional), zone name>,
|
||||
"cost": <float, base cost for shipping. The currency is defined at the stall level>,
|
||||
"regions": [<String, regions included in this zone>],
|
||||
}
|
||||
]
|
||||
"id": <string, id generated by the merchant. Sequential IDs (`0`, `1`, `2`...) are discouraged>,
|
||||
"name": <string, stall name>,
|
||||
"description": <string (optional), stall description>,
|
||||
"currency": <string, currency used>,
|
||||
"shipping": [
|
||||
{
|
||||
"id": <string, id of the shipping zone, generated by the merchant>,
|
||||
"name": <string (optional), zone name>,
|
||||
"cost": <float, base cost for shipping. The currency is defined at the stall level>,
|
||||
"regions": [<string, regions included in this zone>],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -70,34 +71,39 @@ Fields that are not self-explanatory:
|
||||
- each shipping zone contains the base cost for orders made to that shipping zone, but a specific shipping cost per
|
||||
product can also be specified if the shipping cost for that product is higher than what's specified by the base cost.
|
||||
|
||||
**Event Tags**:
|
||||
**Event Tags**
|
||||
|
||||
```json
|
||||
"tags": [["d", <String, id of stall]]
|
||||
{
|
||||
"tags": [["d", <string, id of stall]],
|
||||
...
|
||||
}
|
||||
```
|
||||
- the `d` tag is required, its value MUST be the same as the stall `id`.
|
||||
|
||||
### Event `30018`: Create or update a product
|
||||
|
||||
**Event Content**:
|
||||
**Event Content**
|
||||
|
||||
```json
|
||||
{
|
||||
"id": <String, UUID generated by the merchant.Sequential IDs (`0`, `1`, `2`...) are discouraged>,
|
||||
"stall_id": <String, UUID of the stall to which this product belong to>,
|
||||
"name": <String, product name>,
|
||||
"description": <String (optional), product description>,
|
||||
"images": <[String], array of image URLs, optional>,
|
||||
"currency": <String, currency used>,
|
||||
"price": <float, cost of product>,
|
||||
"quantity": <int or null, available items>,
|
||||
"specs": [
|
||||
[<String, spec key>, <String, spec value>]
|
||||
],
|
||||
"shipping": [
|
||||
{
|
||||
"id": <String, UUID of the shipping zone. Must match one of the zones defined for the stall>,
|
||||
"cost": <float, extra cost for shipping. The currency is defined at the stall level>,
|
||||
}
|
||||
]
|
||||
"id": <string, id generated by the merchant (sequential ids are discouraged)>,
|
||||
"stall_id": <string, id of the stall to which this product belong to>,
|
||||
"name": <string, product name>,
|
||||
"description": <string (optional), product description>,
|
||||
"images": <[string], array of image URLs, optional>,
|
||||
"currency": <string, currency used>,
|
||||
"price": <float, cost of product>,
|
||||
"quantity": <int or null, available items>,
|
||||
"specs": [
|
||||
[<string, spec key>, <string, spec value>]
|
||||
],
|
||||
"shipping": [
|
||||
{
|
||||
"id": <string, id of the shipping zone (must match one of the zones defined for the stall)>,
|
||||
"cost": <float, extra cost for shipping. The currency is defined at the stall level>,
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -114,16 +120,18 @@ Fields that are not self-explanatory:
|
||||
- the `id` should match the id of the shipping zone, as defined in the `shipping` field of the stall
|
||||
- to calculate the total cost of shipping for an order, the user will choose a shipping option during checkout, and then the client must consider this costs:
|
||||
- the `base cost from the stall` for the chosen shipping option
|
||||
- the result of multiplying the product units by the `shipping costs specified in the product`, if any.
|
||||
- the result of multiplying the product units by the `shipping costs specified in the product`, if any.
|
||||
|
||||
**Event Tags**
|
||||
|
||||
**Event Tags**:
|
||||
```json
|
||||
"tags": [
|
||||
["d", <String, id of product],
|
||||
["t", <String (optional), product category],
|
||||
["t", <String (optional), product category],
|
||||
...
|
||||
]
|
||||
["d", <string, id of product],
|
||||
["t", <string (optional), product category],
|
||||
["t", <string (optional), product category],
|
||||
...
|
||||
],
|
||||
...
|
||||
```
|
||||
|
||||
- the `d` tag is required, its value MUST be the same as the product `id`.
|
||||
@@ -147,23 +155,23 @@ The below json goes in content of [NIP04](https://github.com/nostr-protocol/nips
|
||||
|
||||
```json
|
||||
{
|
||||
"id": <String, UUID generated by the customer>,
|
||||
"type": 0,
|
||||
"name": <String (optional), ???>,
|
||||
"address": <String (optional), for physical goods an address should be provided>
|
||||
"message": "<String (optional), message for merchant>,
|
||||
"contact": {
|
||||
"nostr": <32-bytes hex of a pubkey>,
|
||||
"phone": <String (optional), if the customer wants to be contacted by phone>,
|
||||
"email": <String (optional), if the customer wants to be contacted by email>,
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"product_id": <String, UUID of the product>,
|
||||
"quantity": <int, how many products the customer is ordering>
|
||||
}
|
||||
],
|
||||
"shipping_id": <String, UUID of the shipping zone>
|
||||
"id": <string, id generated by the customer>,
|
||||
"type": 0,
|
||||
"name": <string (optional), ???>,
|
||||
"address": <string (optional), for physical goods an address should be provided>
|
||||
"message": "<string (optional), message for merchant>,
|
||||
"contact": {
|
||||
"nostr": <32-bytes hex of a pubkey>,
|
||||
"phone": <string (optional), if the customer wants to be contacted by phone>,
|
||||
"email": <string (optional), if the customer wants to be contacted by email>,
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"product_id": <string, id of the product>,
|
||||
"quantity": <int, how many products the customer is ordering>
|
||||
}
|
||||
],
|
||||
"shipping_id": <string, id of the shipping zone>
|
||||
}
|
||||
|
||||
```
|
||||
@@ -186,23 +194,23 @@ The below json goes in `content` of [NIP04](https://github.com/nostr-protocol/ni
|
||||
|
||||
```json
|
||||
{
|
||||
"id": <String, UUID of the order>,
|
||||
"type": 1,
|
||||
"message": <String, message to customer, optional>,
|
||||
"payment_options": [
|
||||
{
|
||||
"type": <String, option type>,
|
||||
"link": <String, url, btc address, ln invoice, etc>
|
||||
},
|
||||
{
|
||||
"type": <String, option type>,
|
||||
"link": <String, url, btc address, ln invoice, etc>
|
||||
},
|
||||
{
|
||||
"type": <String, option type>,
|
||||
"link": <String, url, btc address, ln invoice, etc>
|
||||
}
|
||||
]
|
||||
"id": <string, id of the order>,
|
||||
"type": 1,
|
||||
"message": <string, message to customer, optional>,
|
||||
"payment_options": [
|
||||
{
|
||||
"type": <string, option type>,
|
||||
"link": <string, url, btc address, ln invoice, etc>
|
||||
},
|
||||
{
|
||||
"type": <string, option type>,
|
||||
"link": <string, url, btc address, ln invoice, etc>
|
||||
},
|
||||
{
|
||||
"type": <string, option type>,
|
||||
"link": <string, url, btc address, ln invoice, etc>
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -214,11 +222,11 @@ The below json goes in `content` of [NIP04](https://github.com/nostr-protocol/ni
|
||||
|
||||
```json
|
||||
{
|
||||
"id": <String, UUID of the order>,
|
||||
"type": 2,
|
||||
"message": <String, message to customer>,
|
||||
"paid": <Bool, true/false has received payment>,
|
||||
"shipped": <Bool, true/false has been shipped>,
|
||||
"id": <string, id of the order>,
|
||||
"type": 2,
|
||||
"message": <string, message to customer>,
|
||||
"paid": <bool: has received payment>,
|
||||
"shipped": <bool: has been shipped>,
|
||||
}
|
||||
```
|
||||
## Customize Marketplace
|
||||
@@ -226,19 +234,20 @@ Create a customized user experience using the `naddr` from [NIP-19](https://gith
|
||||
|
||||
### Event `30019`: Create or update marketplace UI/UX
|
||||
|
||||
**Event Content**:
|
||||
**Event Content**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": <String (optional), market name>,
|
||||
"about": <String (optional), market description>,
|
||||
"ui": {
|
||||
"picture": <String (optional), market logo image URL>,
|
||||
"banner": <String (optional), market logo banner URL>,
|
||||
"theme": <String (optional), market theme>,
|
||||
"darkMode": <Bool, true/false>
|
||||
},
|
||||
"merchants": <[String] (optional), array of pubkeys>,
|
||||
...
|
||||
"name": <string (optional), market name>,
|
||||
"about": <string (optional), market description>,
|
||||
"ui": {
|
||||
"picture": <string (optional), market logo image URL>,
|
||||
"banner": <string (optional), market logo banner URL>,
|
||||
"theme": <string (optional), market theme>,
|
||||
"darkMode": <bool, true/false>
|
||||
},
|
||||
"merchants": [array of pubkeys (optional)],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user