nips/68.md

88 lines
2.2 KiB
Markdown
Raw Normal View History

2024-04-23 15:11:16 -04:00
NIP-68
======
Shared Replaceables
-------------------
`draft` `optional`
2024-04-23 15:24:46 -04:00
This NIP creates replaceable events that can be changed by any public key in the list of pre-defined owners.
2024-04-23 15:11:16 -04:00
2024-04-23 15:24:46 -04:00
The initial creator adds all owners to the `d` tag, separated by `|`. The presence of `|` on the `d` tag, with valid keys for each but the last position, directs clients to work with this event as a shared replaceable.
2024-04-23 15:11:16 -04:00
```js
{
"kind": 3xxxx,
"tags": [
["d", "<pubkey1>|<pubkey2>|<pubkey3>|<identifier>"],
// ...
],
//...
}
```
2024-04-23 15:24:46 -04:00
Clients MUST render the latest event from any of the owners.
2024-04-23 15:11:16 -04:00
To change owners, users MUST create a new `d` tag with new owners and MAY delete the previous one.
# Referencing & Indexing
Events that reference the most recent version of a shared replaceable MUST add `a` tags to each owner.
Reply example:
```jsonc
{
"kind": 1,
"tags": [
["a", "3xxxx:<pubkey1>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>", "<optional-relay-url>", "reply"],
["a", "3xxxx:<pubkey2>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>", "<optional-relay-url>", "reply"],
["a", "3xxxx:<pubkey3>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>", "<optional-relay-url>", "reply"]
],
"content": "a reply",
// ...
}
```
## Deletion
Owners can only unilaterally delete their own events:
```jsonc
{
"pubkey": "<pubkey1>",
"kind": 5,
"tags": [
["a", "3xxxx:<pubkey1>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>", "<optional-relay-url>"],
],
"content": "Deletes my versions of this repleceable",
// ...
}
```
Adding other pubkeys to the `a` tag won't have any effect.
# Filtering
After parsing the desired `d` tag, clients SHOULD create a filter that includes all `d`-tag pubkeys as authors and use the `limit:1` to get only the latest event.
```json
{
"authors": ["<pubkey1>", "<pubkey2>", "<pubkey3>"],
"kinds": [3xxxx],
"#d": ["<pubkey1>|<pubkey2>|<pubkey3>|<identifier>"],
"limit": 1
}
```
To find all events associated with a given shared replaceable, clients SHOULD search for `a` tags from each of the authors:
```json
{
"#a": [
"3xxxx:<pubkey1>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>",
"3xxxx:<pubkey2>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>",
"3xxxx:<pubkey3>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>"
]
}
```