Skip to content

Tag: p

Overview

The "p" tag is a fundamental tag in the Nostr protocol used to reference public keys of other users. It serves as a way to create connections between events and users, enabling mentions, follow lists, and cross-event notifications.

Specification

PropertyValue
Tag Namep
Defined inNIP-01
Required forGeneral use, Kind 1 (text notes mentions), Kind 3 (follow lists), Kind 9735 (zap receipts)

Format

["p", "<32-bytes lowercase hex of a pubkey>", "<recommended relay URL, optional>", "<petname, optional>"]

Usage Description

The "p" tag is used to reference other users in the Nostr ecosystem by their public keys. Its usage varies across different event kinds:

  1. General Reference: When a user wants to reference another user in any event.
  2. Kind 1 (Text Notes): Used to identify users mentioned in a text note, allowing clients to display notifications for users who have been mentioned.
  3. Kind 3 (Follow Lists): Used to maintain a list of public keys that a user follows, optionally with their preferred relay and a "petname" (local nickname).
  4. Kind 9735 (Zap Receipts): Identifies the recipient of a lightning payment.

Tags with a single lowercase letter (like "p") are expected to be indexed by relays, allowing clients to query events that reference specific users with filters like {"#p": ["<pubkey>"]}.

Examples

Basic Example (General Reference)

json
["p", "f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca"]

Follow List Entry (Kind 3)

json
["p", "f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca", "wss://nostr.example.com", "alice"]

Zap Receipt Reference (Kind 9735)

json
["p", "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"]

Client Behavior

Clients should handle the "p" tag in the following ways:

  1. Indexing: Use "p" tags to build a graph of user references and relationships.
  2. Notifications: Display notifications when a user's public key appears in the "p" tag of events.
  3. User Interface: When displaying events with "p" tags, show them as user mentions, potentially with clickable links to user profiles.
  4. Tag Queries: Support filtering events based on "p" tag values, allowing users to see all events mentioning them with queries like {"#p": ["<own-pubkey>"]}.

In text events (Kind 1), clients should compile a list of all public keys involved in a reply thread. When creating a reply, the "p" tags should contain all "p" tags from the original event plus the public key of the event being replied to.

Relay Behavior

Relays should index the "p" tag to enable efficient querying of events that mention specific users. This is important for notification systems and social features within Nostr clients.

References

  • e - Event reference tag
  • a - Addressable/replaceable event reference tag

Notes

The "p" tag is a cornerstone of the Nostr protocol's social functionality, enabling the graph of relationships between users. Its role in enabling cross-event notifications is particularly important for building interactive social applications.

When used in combination with relay URLs, the "p" tag helps clients discover and fetch events from the correct relays for specific users, improving the decentralized discovery mechanism of the protocol.