Class Client<ContentTypes>

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

Type Parameters

  • ContentTypes = any

Constructors

Properties

address: string
apiClient: ApiClient
contacts: Contacts
publicKeyBundle: PublicKeyBundle

Accessors

Methods

  • Check if

    Parameters

    • peerAddress: string

    Returns Promise<boolean>

    Peer Address

    can be messaged, specifically it checks that a PublicKeyBundle can be found for the given address

  • Check if

    Parameters

    • peerAddress: string[]

    Returns Promise<boolean[]>

    Peer Address

    can be messaged, specifically it checks that a PublicKeyBundle can be found for the given address

  • Parameters

    • contentBytes: Uint8Array

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

  • Convert arbitrary content into a serialized EncodedContent instance with the given options

    Parameters

    Returns Promise<Uint8Array>

  • Used to force getUserContact fetch contact from the network.

    Parameters

    • peerAddress: string

    Returns void

  • 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[]>

  • 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>

  • Parameters

    • legacy: boolean = false

    Returns Promise<void>

  • Parameters

    Returns Promise<boolean>

  • Parameters

    Returns Promise<boolean[]>

  • Create and start a client associated with given wallet.

    Type Parameters

    Parameters

    • wallet: null | Signer | {
          account: undefined | Account;
          addChain: ((args) => Promise<void>);
          batch?: {
              multicall?: boolean | {
                  batchSize?: number;
                  wait?: number;
              };
          };
          cacheTime: number;
          chain: undefined | Chain;
          deployContract: (<const TAbi, TChainOverride>(args) => Promise<`0x${string}`>);
          extend: (<const client>(fn) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, {
              [K in string | number | symbol]: client[K]
          } & WalletActions<undefined | Chain, undefined | Account>>);
          getAddresses: (() => Promise<GetAddressesReturnType>);
          getChainId: (() => Promise<number>);
          getPermissions: (() => Promise<GetPermissionsReturnType>);
          key: string;
          name: string;
          pollingInterval: number;
          prepareTransactionRequest: (<TChainOverride>(args) => Promise<PrepareTransactionRequestReturnType>);
          request: EIP1193RequestFn<WalletRpcSchema>;
          requestAddresses: (() => Promise<RequestAddressesReturnType>);
          requestPermissions: ((args) => Promise<RequestPermissionsReturnType>);
          sendRawTransaction: ((args) => Promise<`0x${string}`>);
          sendTransaction: (<TChainOverride>(args) => Promise<`0x${string}`>);
          signMessage: ((args) => Promise<`0x${string}`>);
          signTransaction: (<TChainOverride>(args) => Promise<`0x${string}`>);
          signTypedData: (<const TTypedData, TPrimaryType>(args) => Promise<`0x${string}`>);
          switchChain: ((args) => Promise<void>);
          transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>;
          type: string;
          uid: string;
          watchAsset: ((args) => Promise<boolean>);
          writeContract: (<const TAbi, TFunctionName, TChainOverride>(args) => Promise<`0x${string}`>);
      }

      the wallet as a Signer instance

    • Optional opts: Partial<Flatten<NetworkOptions & KeyStoreOptions & ContentOptions & LegacyOptions & PreEventCallbackOptions>> & {
          codecs?: ContentCodecs;
      }

      specify how to to connect to the network

    Returns Promise<Client<undefined | ExtractDecodedType<[...ContentCodecs[], TextCodec][number]>>>

  • 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

    • wallet: null | Signer | {
          account: undefined | Account;
          addChain: ((args) => Promise<void>);
          batch?: {
              multicall?: boolean | {
                  batchSize?: number;
                  wait?: number;
              };
          };
          cacheTime: number;
          chain: undefined | Chain;
          deployContract: (<const TAbi, TChainOverride>(args) => Promise<`0x${string}`>);
          extend: (<const client>(fn) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, {
              [K in string | number | symbol]: client[K]
          } & WalletActions<undefined | Chain, undefined | Account>>);
          getAddresses: (() => Promise<GetAddressesReturnType>);
          getChainId: (() => Promise<number>);
          getPermissions: (() => Promise<GetPermissionsReturnType>);
          key: string;
          name: string;
          pollingInterval: number;
          prepareTransactionRequest: (<TChainOverride>(args) => Promise<PrepareTransactionRequestReturnType>);
          request: EIP1193RequestFn<WalletRpcSchema>;
          requestAddresses: (() => Promise<RequestAddressesReturnType>);
          requestPermissions: ((args) => Promise<RequestPermissionsReturnType>);
          sendRawTransaction: ((args) => Promise<`0x${string}`>);
          sendTransaction: (<TChainOverride>(args) => Promise<`0x${string}`>);
          signMessage: ((args) => Promise<`0x${string}`>);
          signTransaction: (<TChainOverride>(args) => Promise<`0x${string}`>);
          signTypedData: (<const TTypedData, TPrimaryType>(args) => Promise<`0x${string}`>);
          switchChain: ((args) => Promise<void>);
          transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>;
          type: string;
          uid: string;
          watchAsset: ((args) => Promise<boolean>);
          writeContract: (<const TAbi, TFunctionName, TChainOverride>(args) => Promise<`0x${string}`>);
      }
    • Optional opts: Partial<Flatten<NetworkOptions & KeyStoreOptions & ContentOptions & LegacyOptions & PreEventCallbackOptions>> & {
          codecs?: U;
      }

    Returns Promise<Uint8Array>

  • Tells the caller whether the browser has a Snaps-compatible version of MetaMask installed

    Returns Promise<boolean>

Generated using TypeDoc