Skip to main content

Client

Class: Client

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

Constructors

constructor

new Client(keys, apiClient)

Parameters

NameType
keysPrivateKeyBundleV1
apiClientdefault

Defined in

Client.ts:136

Properties

_codecs

Private _codecs: Map<string, ContentCodec<any>>

Defined in

Client.ts:133


_conversations

Private _conversations: Conversations

Defined in

Client.ts:132


_maxContentSize

Private _maxContentSize: number

Defined in

Client.ts:134


address

address: string

Defined in

Client.ts:127


apiClient

apiClient: default

Defined in

Client.ts:129


contacts

Private contacts: Set<string>

Defined in

Client.ts:130


keys

keys: PrivateKeyBundleV1

Defined in

Client.ts:128


knownPublicKeyBundles

Private knownPublicKeyBundles: Map<string, PublicKeyBundle>

Defined in

Client.ts:131

Accessors

conversations

get conversations(): Conversations

Returns

Conversations

Defined in

Client.ts:150

Methods

canMessage

canMessage(peerAddress): Promise<boolean>

Check if

Peer Address

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

Parameters

NameType
peerAddressstring

Returns

Promise<boolean>

Defined in

Client.ts:233


close

close(): Promise<void>

Returns

Promise<void>

Defined in

Client.ts:190


codecFor

codecFor(contentType): undefined | ContentCodec<any>

Parameters

NameType
contentTypeContentTypeId

Returns

undefined | ContentCodec<any>

Defined in

Client.ts:320


decodeMessage

decodeMessage(payload, contentTopic): Promise<Message>

Parameters

NameType
payloadUint8Array
contentTopicundefined | string

Returns

Promise<Message>

Defined in

Client.ts:355


encodeMessage

encodeMessage(recipient, timestamp, content, options?): Promise<Message>

Parameters

NameType
recipientPublicKeyBundle
timestampDate
contentany
options?SendOptions

Returns

Promise<Message>

Defined in

Client.ts:332


getUserContact

getUserContact(peerAddress): Promise<undefined | PublicKeyBundle>

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

Parameters

NameType
peerAddressstring

Returns

Promise<undefined | PublicKeyBundle>

Defined in

Client.ts:208


init

init(options): Promise<void>

Parameters

NameType
optionsClientOptions

Returns

Promise<void>

Defined in

Client.ts:181


listConversationMessages

listConversationMessages(peerAddress, opts?): Promise<Message[]>

Parameters

NameType
peerAddressstring
opts?ListMessagesOptions

Returns

Promise<Message[]>

Defined in

Client.ts:411


listIntroductionMessages

listIntroductionMessages(opts?): Promise<Message[]>

Parameters

NameType
opts?ListMessagesOptions

Returns

Promise<Message[]>

Defined in

Client.ts:406


listMessages

Private listMessages(topic, opts?): Promise<Message[]>

Parameters

NameType
topicstring
opts?ListMessagesOptions

Returns

Promise<Message[]>

Defined in

Client.ts:422


publishEnvelope

publishEnvelope(env): Promise<void>

Parameters

NameType
envEnvelope

Returns

Promise<void>

Defined in

Client.ts:292


publishUserContact

Private publishUserContact(): Promise<void>

Returns

Promise<void>

Defined in

Client.ts:195


registerCodec

registerCodec(codec): void

Parameters

NameType
codecContentCodec<any>

Returns

void

Defined in

Client.ts:314


sendMessage

sendMessage(peerAddress, content, options?): Promise<Message>

Send a message to the wallet identified by

Peer Address

Parameters

NameType
peerAddressstring
contentany
options?SendOptions

Returns

Promise<Message>

Defined in

Client.ts:253


streamConversationMessages

streamConversationMessages(peerAddress): Promise<Stream<Message>>

Parameters

NameType
peerAddressstring

Returns

Promise<Stream<Message>>

Defined in

Client.ts:395


streamIntroductionMessages

streamIntroductionMessages(): Promise<Stream<Message>>

Returns

Promise<Stream<Message>>

Defined in

Client.ts:387


canMessage

Static canMessage(peerAddress, opts?): Promise<boolean>

Parameters

NameType
peerAddressstring
opts?Partial<NetworkOptions>

Returns

Promise<boolean>

Defined in

Client.ts:238


create

Static create(wallet, opts?): Promise<Client>

Create and start a client associated with given wallet.

Parameters

NameTypeDescription
walletnull | Signerthe wallet as a Signer instance
opts?Partial<ClientOptions>specify how to to connect to the network

Returns

Promise<Client>

Defined in

Client.ts:160


getKeys

Static getKeys(wallet, opts?): Promise<Uint8Array>

Parameters

NameType
walletnull | Signer
opts?Partial<ClientOptions>

Returns

Promise<Uint8Array>

Defined in

Client.ts:173