Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client<ContentTypes>

Client class initiates connection to the XMTP network. Should be created with await Client.create(options)

Type parameters

  • ContentTypes = any

Hierarchy

  • Client

Index

Constructors

Properties

address: string
apiClient: ApiClient
contacts: Set<string>
keystore: Keystore
publicKeyBundle: PublicKeyBundle

Accessors

  • get backupType(): BackupType

Methods

  • canMessage(peerAddress: string): Promise<boolean>
  • canMessage(peerAddress: string[]): Promise<boolean[]>
  • Check if @peerAddress can be messaged, specifically it checks that a PublicKeyBundle can be found for the given address

    Parameters

    • peerAddress: string

    Returns Promise<boolean>

  • Check if @peerAddress can be messaged, specifically it checks that a PublicKeyBundle can be found for the given address

    Parameters

    • peerAddress: string[]

    Returns Promise<boolean[]>

  • close(): Promise<void>
  • decodeContent(contentBytes: Uint8Array): Promise<{ content: ContentTypes; contentFallback?: string; contentType: ContentTypeId; error?: Error }>
  • Parameters

    • contentBytes: Uint8Array

    Returns Promise<{ content: ContentTypes; contentFallback?: string; contentType: ContentTypeId; error?: Error }>

  • encodeContent(content: ContentTypes, options?: SendOptions): Promise<Uint8Array>
  • Convert arbitrary content into a serialized EncodedContent instance with the given options

    Parameters

    Returns Promise<Uint8Array>

  • forgetContact(peerAddress: string): void
  • Used to force getUserContact fetch contact from the network.

    Parameters

    • peerAddress: string

    Returns void

  • Returns the cached PublicKeyBundle if one is known for the given address or fetches one from the network

    This throws if either the address is invalid or the contact is not published. See also [#canMessage].

    Parameters

    • peerAddress: string

    Returns Promise<undefined | PublicKeyBundle | SignedPublicKeyBundle>

  • listEnvelopes<Out>(topic: string, mapper: EnvelopeMapper<Out>, opts?: ListMessagesOptions): Promise<Out[]>
  • List stored messages from the specified topic.

    A specified mapper function will be applied to each envelope. If the mapper function throws an error during processing, the envelope will be discarded.

    Type parameters

    • Out

    Parameters

    Returns Promise<Out[]>

  • listEnvelopesPaginated<Out>(contentTopic: string, mapper: EnvelopeMapper<Out>, opts?: ListMessagesPaginatedOptions): AsyncGenerator<Out[], any, unknown>
  • List messages on a given set of content topics, yielding one page at a time

    Type parameters

    • Out

    Parameters

    Returns AsyncGenerator<Out[], any, unknown>

  • Low level method for publishing envelopes to the XMTP network with no pre-processing or encryption applied.

    Primarily used internally

    Parameters

    Returns Promise<void>

  • publishUserContact(legacy?: boolean): Promise<void>
  • Parameters

    • legacy: boolean = false

    Returns Promise<void>

  • Register a codec to be automatically used for encoding/decoding messages of the given Content Type

    Type parameters

    Parameters

    • codec: Codec

    Returns Client<ContentTypes | ExtractDecodedType<Codec>>

  • canMessage(peerAddress: string, opts?: Partial<NetworkOptions>): Promise<boolean>
  • canMessage(peerAddress: string[], opts?: Partial<NetworkOptions>): Promise<boolean[]>
  • Export the XMTP PrivateKeyBundle from the SDK as a Uint8Array.

    This bundle can then be provided as privateKeyOverride in a subsequent call to Client.create(...)

    Be very careful with these keys, as they can be used to impersonate a user on the XMTP network and read the user's messages.

    Type parameters

    • U

    Parameters

    Returns Promise<Uint8Array>

  • isSnapsReady(): Promise<boolean>
  • Tells the caller whether the browser has a Snaps-compatible version of MetaMask installed

    Returns Promise<boolean>

Generated using TypeDoc