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:158

Properties

_codecs

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

Defined in

Client.ts:155


_conversations

Private _conversations: Conversations

Defined in

Client.ts:153


_maxContentSize

Private _maxContentSize: number

Defined in

Client.ts:156


address

address: string

Defined in

Client.ts:143


apiClient

apiClient: default

Defined in

Client.ts:146


contacts

contacts: Set<string>

Defined in

Client.ts:147


keys

keys: PrivateKeyBundleV2

Defined in

Client.ts:145


knownPublicKeyBundles

Private knownPublicKeyBundles: Map<string, SignedPublicKeyBundle | PublicKeyBundle>

Defined in

Client.ts:148


legacyKeys

legacyKeys: PrivateKeyBundleV1

Defined in

Client.ts:144

Accessors

conversations

get conversations(): Conversations

Returns

Conversations

Defined in

Client.ts:176

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:287


close

close(): Promise<void>

Returns

Promise<void>

Defined in

Client.ts:216


codecFor

codecFor(contentType): undefined | ContentCodec<any>

Parameters

NameType
contentTypeContentTypeId

Returns

undefined | ContentCodec<any>

Defined in

Client.ts:334


encodeContent

encodeContent(content, options?): Promise<Uint8Array>

Parameters

NameType
contentany
options?SendOptions

Returns

Promise<Uint8Array>

Defined in

Client.ts:346


ensureUserContactPublished

Private ensureUserContactPublished(legacy?): Promise<void>

Parameters

NameTypeDefault value
legacybooleanfalse

Returns

Promise<void>

Defined in

Client.ts:220


forgetContact

forgetContact(peerAddress): void

Used to force getUserContact fetch contact from the network.

Parameters

NameType
peerAddressstring

Returns

void

Defined in

Client.ts:279


getUserContact

getUserContact(peerAddress): Promise<undefined | SignedPublicKeyBundle | 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 | SignedPublicKeyBundle | PublicKeyBundle>

Defined in

Client.ts:255


init

Private init(options): Promise<void>

Parameters

NameType
optionsClientOptions

Returns

Promise<void>

Defined in

Client.ts:207


listEnvelopes

listEnvelopes<Out>(topics, mapper, opts?): Promise<Out[]>

Type parameters

Name
Out

Parameters

NameType
topicsstring[]
mapperEnvelopeMapper<Out>
opts?ListMessagesOptions

Returns

Promise<Out[]>

Defined in

Client.ts:376


listEnvelopesPaginated

listEnvelopesPaginated<Out>(contentTopics, mapper, opts?): AsyncGenerator<Out[], any, unknown>

List messages on a given set of content topics, yielding one page at a time

Type parameters

Name
Out

Parameters

NameType
contentTopicsstring[]
mapperEnvelopeMapper<Out>
opts?ListMessagesPaginatedOptions

Returns

AsyncGenerator<Out[], any, unknown>

Defined in

Client.ts:410


listInvitations

listInvitations(opts?): Promise<SealedInvitation[]>

Parameters

NameType
opts?ListMessagesOptions

Returns

Promise<SealedInvitation[]>

Defined in

Client.ts:367


publishEnvelopes

publishEnvelopes(envelopes): Promise<void>

Parameters

NameType
envelopesPublishParams[]

Returns

Promise<void>

Defined in

Client.ts:315


publishUserContact

publishUserContact(legacy?): Promise<void>

Parameters

NameTypeDefault value
legacybooleanfalse

Returns

Promise<void>

Defined in

Client.ts:240


registerCodec

registerCodec(codec): void

Parameters

NameType
codecContentCodec<any>

Returns

void

Defined in

Client.ts:327


validateEnvelope

Private validateEnvelope(env): void

Parameters

NameType
envPublishParams

Returns

void

Defined in

Client.ts:304


canMessage

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

Parameters

NameType
peerAddressstring
opts?Partial<NetworkOptions>

Returns

Promise<boolean>

Defined in

Client.ts:292


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:186


getKeys

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

Parameters

NameType
walletnull | Signer
opts?Partial<ClientOptions>

Returns

Promise<Uint8Array>

Defined in

Client.ts:199