Nostr. Event. Metadata
(Nostr Lib v0.2.1)
(event)
(nip01)
(nip24)
(nip30)
(nip39)
View Source
User metadata (Kind 0)
Implements NIP-01 (basic metadata), NIP-24 (extra metadata fields), NIP-30 (custom emoji), and NIP-39 (external identities).
NIP-01 Fields
name- usernameabout- bio/descriptionpicture- avatar URLnip05- NIP-05 identifier
NIP-24 Extra Fields
display_name- alternative, richer display namewebsite- web URL related to the userbanner- wide background picture URL (~1024x768)bot- boolean indicating automated contentbirthday- birth date with optional year/month/day
NIP-30 Custom Emoji
emojis- map of shortcode => URL for custom emoji innameandabout
NIP-39 External Identities
identities- list of external identity verifications (github, twitter, mastodon, telegram)
Examples
# Create basic metadata
Metadata.create("alice", "About me", "https://pic.com/a.jpg", "alice@example.com")
# Create with NIP-24 fields
Metadata.create("alice", "About me", "https://pic.com/a.jpg", "alice@example.com",
display_name: "Alice Wonderland",
website: "https://alice.example.com",
banner: "https://pic.com/banner.jpg",
bot: false,
birthday: %{year: 1990, month: 1, day: 15}
)
# Create with custom emoji (NIP-30)
Metadata.create("Alice :verified:", "About me", nil, nil,
emojis: %{"verified" => "https://example.com/verified.png"}
)
# Create with external identities (NIP-39)
Metadata.create("alice", "About me", nil, nil,
identities: [
%{platform: "github", identity: "alice", proof: "gist_id"},
%{platform: "twitter", identity: "alice_btc", proof: "tweet_id"}
]
)See:
Summary
Functions
Create new Nostr.Event.Metadata struct.
Parse generic Nostr.Event to Nostr.Event.Metadata struct.
Types
@type birthday() :: %{year: non_neg_integer() | nil, month: 1..12 | nil, day: 1..31 | nil} | nil
Birthday with optional year/month/day
@type t() :: %Nostr.Event.Metadata{ about: String.t() | nil, banner: URI.t() | nil, birthday: birthday(), bot: boolean() | nil, display_name: String.t() | nil, emojis: %{required(binary()) => binary()}, event: Nostr.Event.t(), identities: [Nostr.NIP39.identity()], name: String.t() | nil, nip05: String.t() | nil, other: map(), picture: URI.t() | nil, user: binary(), website: URI.t() | nil }
Functions
@spec create( name :: String.t() | nil, about :: String.t() | nil, picture :: URI.t() | String.t() | nil, nip05 :: String.t() | nil, opts :: Keyword.t() ) :: t()
Create new Nostr.Event.Metadata struct.
Arguments
name- usernameabout- bio/descriptionpicture- avatar URL (URI struct or String)nip05- NIP-05 identifieropts- keyword list of options
Options
Event options:
:pubkey- author pubkey:created_at- timestamp:tags- additional tags
NIP-24 fields:
:display_name- alternative, richer display name:website- web URL (String or URI):banner- background picture URL (String or URI):bot- boolean indicating automated content:birthday- map with optional:year,:month,:daykeys
NIP-30 fields:
:emojis- map of shortcode => URL for custom emoji innameandabout
NIP-39 fields:
:identities- list of identity maps with:platform,:identity,:proofkeys
Examples
Metadata.create("alice", "About me", "https://pic.com/a.jpg", "alice@example.com")
Metadata.create("alice", "About me", "https://pic.com/a.jpg", "alice@example.com",
display_name: "Alice Wonderland",
website: "https://alice.example.com",
banner: "https://pic.com/banner.jpg",
bot: false,
birthday: %{year: 1990, month: 1, day: 15}
)
@spec parse(event :: Nostr.Event.t()) :: t() | {:error, String.t(), Nostr.Event.t()}
Parse generic Nostr.Event to Nostr.Event.Metadata struct.
Handles deprecated field normalization:
displayName→display_nameusername→name