nips/68.md
2024-04-23 15:24:46 -04:00

2.2 KiB

NIP-68

Shared Replaceables

draft optional

This NIP creates replaceable events that can be changed by any public key in the list of pre-defined owners.

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.

{
  "kind": 3xxxx,
  "tags": [
    ["d", "<pubkey1>|<pubkey2>|<pubkey3>|<identifier>"],
    // ...
  ],
  //...
}

Clients MUST render the latest event from any of the owners.

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:

{
  "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:

{
  "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.

{
  "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:

{
  "#a": [
    "3xxxx:<pubkey1>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>", 
    "3xxxx:<pubkey2>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>", 
    "3xxxx:<pubkey3>:<pubkey1>|<pubkey2>|<pubkey3>|<identifier>"
  ]
}