nips/02.md

81 lines
3.4 KiB
Markdown
Raw Normal View History

2022-05-01 06:48:57 -04:00
NIP-02
======
Contact List and Petnames
-------------------------
`final` `optional` `author:fiatjaf` `author:arcbtc`
2022-05-01 06:48:57 -04:00
2023-07-13 20:48:16 -04:00
A special event with kind `3`, meaning "contact list" is defined as having a list of `p`, `t`, `r`, `e` or `a` tags, one for each of the profiles, hashtags and other events such as communities or chats one is following.
2022-05-01 06:48:57 -04:00
Each `p` tag entry should contain the key for the profile, a relay URL where events from that key can be found (can be set to an empty string if not needed), and a local name (or "petname") for that profile (can also be set to an empty string or not provided), i.e., `["p", <32-bytes hex key>, <main relay URL>, <petname>]`. The `content` can be anything and should be ignored.
2023-07-13 20:52:12 -04:00
Clients are not expected to support all types of follows, but MUST not delete unsupported tags when updating the contact list.
2022-05-01 06:48:57 -04:00
For example:
```js
2022-05-01 06:48:57 -04:00
{
"kind": 3,
"tags": [
["p", "91cf9..4e5ca", "wss://alicerelay.com/", "alice"],
["p", "14aeb..8dad4", "wss://bobrelay.com/nostr", "bob"],
["p", "612ae..e610f", "ws://carolrelay.com/ws", "carol"],
2023-07-13 20:55:17 -04:00
["t", "intro"] // hashtag
["r", "http://mywebsite.com"] // url follows
["a", "34550:3f770d65d3a764a9c5cb503ae123e62ec7598ad035d836e2a810f3877a745b24:android", "ws://carolrelay.com/ws"] // Android kind:34550 moderated community
["e", "25e5c82273a271cb1a840d0060391a0bf4965cafeb029d5ab55350b418953fbb", "ws://carolrelay.com/ws"] // Nostr Public Chat kind:40 Creation Event
2022-05-01 06:48:57 -04:00
],
"content": "",
...other fields
2023-03-06 13:14:45 -05:00
}
2022-05-01 06:48:57 -04:00
```
Every new contact list that gets published overwrites the past ones, so it should contain all entries. Relays and clients SHOULD delete past contact lists as soon as they receive a new one.
## Uses
### Contact list backup
If one believes a relay will store their events for sufficient time, they can use this kind-3 event to backup their following list and recover on a different device.
### Profile discovery and context augmentation
A client may rely on the kind-3 event to display a list of followed people by profiles one is browsing; make lists of suggestions on who to follow based on the contact lists of other people one might be following or browsing; or show the data in other contexts.
### Relay sharing
2023-01-15 15:38:10 -05:00
A client may publish a full list of contacts with good relays for each of their contacts so other clients may use these to update their internal relay lists if needed, increasing censorship-resistance.
2022-05-01 06:48:57 -04:00
### Petname scheme
The data from these contact lists can be used by clients to construct local ["petname"](http://www.skyhunter.com/marcs/petnames/IntroPetNames.html) tables derived from other people's contact lists. This alleviates the need for global human-readable names. For example:
A user has an internal contact list that says
```json
[
["p", "21df6d143fb96c2ec9d63726bf9edc71", "", "erin"]
2022-05-01 06:48:57 -04:00
]
```
And receives two contact lists, one from `21df6d143fb96c2ec9d63726bf9edc71` that says
```json
[
["p", "a8bb3d884d5d90b413d9891fe4c4e46d", "", "david"]
2022-05-01 06:48:57 -04:00
]
```
and another from `a8bb3d884d5d90b413d9891fe4c4e46d` that says
```json
[
["p", "f57f54057d2a7af0efecc8b0b66f5708", "", "frank"]
2022-05-01 06:48:57 -04:00
]
```
When the user sees `21df6d143fb96c2ec9d63726bf9edc71` the client can show _erin_ instead;
When the user sees `a8bb3d884d5d90b413d9891fe4c4e46d` the client can show _david.erin_ instead;
When the user sees `f57f54057d2a7af0efecc8b0b66f5708` the client can show _frank.david.erin_ instead.