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
| Name | Type |
|---|---|
keys | PrivateKeyBundleV1 |
apiClient | default |
Defined in
Properties
_codecs
Private _codecs: Map<string, ContentCodec<any>>
Defined in
_conversations
Private _conversations: Conversations
Defined in
_maxContentSize
Private _maxContentSize: number
Defined in
address
address: string
Defined in
apiClient
apiClient: default
Defined in
contacts
Private contacts: Set<string>
Defined in
keys
keys: PrivateKeyBundleV1
Defined in
knownPublicKeyBundles
Private knownPublicKeyBundles: Map<string, PublicKeyBundle>
Defined in
Accessors
conversations
get conversations(): Conversations
Returns
Defined in
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
| Name | Type |
|---|---|
peerAddress | string |
Returns
Promise<boolean>
Defined in
close
close(): Promise<void>
Returns
Promise<void>
Defined in
codecFor
codecFor(contentType): undefined | ContentCodec<any>
Parameters
| Name | Type |
|---|---|
contentType | ContentTypeId |
Returns
undefined | ContentCodec<any>
Defined in
decodeMessage
decodeMessage(payload, contentTopic): Promise<Message>
Parameters
| Name | Type |
|---|---|
payload | Uint8Array |
contentTopic | undefined | string |
Returns
Promise<Message>
Defined in
encodeMessage
encodeMessage(recipient, timestamp, content, options?): Promise<Message>
Parameters
| Name | Type |
|---|---|
recipient | PublicKeyBundle |
timestamp | Date |
content | any |
options? | SendOptions |
Returns
Promise<Message>
Defined in
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
| Name | Type |
|---|---|
peerAddress | string |
Returns
Promise<undefined | PublicKeyBundle>
Defined in
init
init(options): Promise<void>
Parameters
| Name | Type |
|---|---|
options | ClientOptions |
Returns
Promise<void>
Defined in
listConversationMessages
listConversationMessages(peerAddress, opts?): Promise<Message[]>
Parameters
| Name | Type |
|---|---|
peerAddress | string |
opts? | ListMessagesOptions |
Returns
Promise<Message[]>
Defined in
listIntroductionMessages
listIntroductionMessages(opts?): Promise<Message[]>
Parameters
| Name | Type |
|---|---|
opts? | ListMessagesOptions |
Returns
Promise<Message[]>
Defined in
listMessages
Private listMessages(topic, opts?): Promise<Message[]>
Parameters
| Name | Type |
|---|---|
topic | string |
opts? | ListMessagesOptions |
Returns
Promise<Message[]>
Defined in
publishEnvelope
publishEnvelope(env): Promise<void>
Parameters
| Name | Type |
|---|---|
env | Envelope |
Returns
Promise<void>
Defined in
publishUserContact
Private publishUserContact(): Promise<void>
Returns
Promise<void>
Defined in
registerCodec
registerCodec(codec): void
Parameters
| Name | Type |
|---|---|
codec | ContentCodec<any> |
Returns
void
Defined in
sendMessage
sendMessage(peerAddress, content, options?): Promise<Message>
Send a message to the wallet identified by
Peer Address
Parameters
| Name | Type |
|---|---|
peerAddress | string |
content | any |
options? | SendOptions |
Returns
Promise<Message>
Defined in
streamConversationMessages
streamConversationMessages(peerAddress): Promise<Stream<Message>>
Parameters
| Name | Type |
|---|---|
peerAddress | string |
Returns
Defined in
streamIntroductionMessages
streamIntroductionMessages(): Promise<Stream<Message>>
Returns
Defined in
canMessage
Static canMessage(peerAddress, opts?): Promise<boolean>
Parameters
| Name | Type |
|---|---|
peerAddress | string |
opts? | Partial<NetworkOptions> |
Returns
Promise<boolean>
Defined in
create
Static create(wallet, opts?): Promise<Client>
Create and start a client associated with given wallet.
Parameters
| Name | Type | Description |
|---|---|---|
wallet | null | Signer | the wallet as a Signer instance |
opts? | Partial<ClientOptions> | specify how to to connect to the network |
Returns
Promise<Client>
Defined in
getKeys
Static getKeys(wallet, opts?): Promise<Uint8Array>
Parameters
| Name | Type |
|---|---|
wallet | null | Signer |
opts? | Partial<ClientOptions> |
Returns
Promise<Uint8Array>