Nostr.Event.RelaySets (Nostr Lib v0.2.1) (event) (nip51)

View Source

Relay Sets (Kind 30002)

User-defined relay groups the user can easily pick and choose from during various operations. This is an addressable event with a d tag identifier.

Sets can have optional metadata: title, image, and description.

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

Summary

Functions

Creates a new relay set (kind 30002).

Parses a kind 30002 event into a RelaySets struct.

Types

t()

@type t() :: %Nostr.Event.RelaySets{
  description: binary() | nil,
  event: Nostr.Event.t(),
  identifier: binary(),
  image: binary() | nil,
  relays: [URI.t()],
  title: binary() | nil
}

Functions

create(identifier, relay_urls, opts \\ [])

@spec create(binary(), [binary()], Keyword.t()) :: t()

Creates a new relay set (kind 30002).

Arguments

  • identifier - Unique identifier for this set (used in d tag)
  • relay_urls - List of relay URLs to include in the set
  • opts - Optional event arguments and set metadata

Options

  • :title - Set title for display
  • :image - Set image URL
  • :description - Set description
  • :pubkey - Event author pubkey
  • :created_at - Event timestamp

Example

RelaySets.create("high-quality", ["wss://relay1.com", "wss://relay2.com"],
  title: "High Quality Relays",
  description: "Relays with good uptime and moderation"
)

parse(event)

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

Parses a kind 30002 event into a RelaySets struct.