Class NDKUser

Represents a pubkey.

Constructors

Properties

follows: ((...args: [opts?: NDKSubscriptionOptions, outbox?: boolean, kind: number]) => Promise<Set<NDKUser>>) = ...

Returns a set of users that this user follows.

ndk: undefined | default
nip46Urls: string[] = []
profile?: NDKUserProfile
relayUrls: string[] = []

Accessors

  • get hexpubkey(): string
  • Get the user's hexpubkey

    Returns string

    The user's hexpubkey

    Use pubkey instead

  • set hexpubkey(pubkey: string): void
  • Set the user's hexpubkey

    Parameters

    • pubkey: string

      {Hexpubkey} The user's hexpubkey

    Returns void

    Use pubkey instead

  • get pubkey(): string
  • Get the user's pubkey

    Returns string

    The user's pubkey

  • set pubkey(pubkey: string): void
  • Set the user's pubkey

    Parameters

    • pubkey: string

      {string} The user's pubkey

    Returns void

Methods

  • Add a follow to this user's contact list

    Parameters

    • newFollow: NDKUser

      {NDKUser} The user to follow

    • OptionalcurrentFollowList: Set<NDKUser>

      {Set} The current follow list

    • kind: NDKKind = NDKKind.Contacts

      {NDKKind} The kind to use for this contact list (defaults to 3)

    Returns Promise<boolean>

    True if the follow was added, false if the follow already exists

  • Fetches the zapper's pubkey for the zapped user

    Returns Promise<undefined | string>

    The zapper's pubkey if one can be found

  • Get the tags that can be used to reference this user in an event

    Parameters

    • Optionalmarker: string

    Returns NDKTag[]

    an array of NDKTag

  • Remove a follow from this user's contact list

    Parameters

    • user: NDKUser

      {NDKUser} The user to unfollow

    • OptionalcurrentFollowList: Set<NDKUser>

      {Set} The current follow list

    • kind: NDKKind = NDKKind.Contacts

      {NDKKind} The kind to use for this contact list (defaults to 3)

    Returns Promise<boolean | Set<NDKRelay>>

    The relays were the follow list was published or false if the user wasn't found

  • Validate a user's NIP-05 identifier (usually fetched from their kind:0 profile data)

    Parameters

    • nip05Id: string

      The NIP-05 string to validate

    Returns Promise<null | boolean>

    True if the NIP-05 is found and matches this user's pubkey, False if the NIP-05 is found but doesn't match this user's pubkey, null if the NIP-05 isn't found on the domain or we're unable to verify (because of network issues, etc.)

  • Zap a user

    Parameters

    • amount: number

      The amount to zap in millisatoshis

    • Optionalcomment: string

      A comment to add to the zap request

    • Optionaltags: NDKTag[]
    • Optionalsigner: NDKSigner

      The signer to use (will default to the NDK instance's signer)

    Returns Promise<unknown>

  • Instantiate an NDKUser from a NIP-05 string

    Parameters

    • nip05Id: string

      {string} The user's NIP-05

    • ndk: default

      {NDK} An NDK instance

    • skipCache: boolean = false

      {boolean} Whether to skip the cache or not

    Returns Promise<undefined | NDKUser>

    An NDKUser if one is found for the given NIP-05, undefined otherwise.