Nostr.Tag (Nostr Lib v0.2.0)
View SourceNostr Event tag.
Tags are metadata attached to events. Common tag types:
:e- references another event (event ID):p- references a pubkey (user mention):a- references a parameterized replaceable event:d- identifier for parameterized replaceable events:relay- relay URL:challenge- authentication challenge
The wire format is a JSON array: ["type", "data", ...additional_info]
Summary
Types
Functions
Create new Nostr tag
Each tag needs to have type and at least one data field. If tag requires more then one data field supply them as third argument (list of strings)
Example:
iex> Nostr.Tag.create(:e, "event-id", ["wss://relay.example.com"])
%Nostr.Tag{type: :e, data: "event-id", info: ["wss://relay.example.com"]}
iex> Nostr.Tag.create(:p, "pubkey")
%Nostr.Tag{type: :p, data: "pubkey", info: []}
@spec parse(tag :: nonempty_maybe_improper_list()) :: t()
Parses a JSON tag array ["type", "data", ...info] into a Tag struct.
The first element becomes the type (converted to atom), second is data, and any remaining elements go into the info list.