Nostr.Event.Contacts (Nostr Lib v0.2.1) (event) (nip02)

View Source

Contact list

Defined in NIP 02 https://github.com/nostr-protocol/nips/blob/master/02.md

Summary

Types

Contact structure returned from parsing

Contact input for creating a contact list

t()

Functions

Create new Contact List (follow list) Nostr event

Parses a kind 3 event into a Contacts struct, extracting the contact list.

Types

contact()

@type contact() :: %{
  :user => <<_::32, _::_*8>>,
  optional(:relay) => URI.t(),
  optional(:petname) => String.t()
}

Contact structure returned from parsing

contact_input()

@type contact_input() :: %{
  :user => binary(),
  optional(:relay) => String.t(),
  optional(:petname) => String.t()
}

Contact input for creating a contact list

t()

@type t() :: %Nostr.Event.Contacts{
  contacts: [contact()],
  event: Nostr.Event.t(),
  user: <<_::32, _::_*8>>
}

Functions

create(contacts, opts \\ [])

@spec create(contacts :: [contact_input()], opts :: Keyword.t()) :: t()

Create new Contact List (follow list) Nostr event

Arguments:

  • contacts list of contacts to follow
  • opts other optional event arguments (pubkey, created_at, tags)

Examples

iex> contacts = [
...>   %{user: "pubkey1", relay: "wss://relay.com", petname: "alice"},
...>   %{user: "pubkey2", relay: "wss://relay.com"},
...>   %{user: "pubkey3"}
...> ]
iex> Nostr.Event.Contacts.create(contacts)

parse(event)

@spec parse(event :: Nostr.Event.t()) :: t()

Parses a kind 3 event into a Contacts struct, extracting the contact list.