Chat

Class that handles sending, retrieving and listening for events related to chat on-chain storage.

Usage

Below is a minimal example of how to initialize Chat (with no optional parameters). It's highly recommended to also use your own appId.

import { Chat } from '@4thtech-sdk/ethereum';

const chat = new Chat({
  walletClient,
});

Parameters

config

  • Type ChatConfig

The configuration object required to initialize the chat client.

config.walletClient

  • Type WalletClient

An instance of the wallet client that takes care of sending Ethereum transactions.

config.appId (Optional)

  • Type AppId
  • Default 0x0000000000000000000000000000000000000000000000000000000000000000

A unique identifier for your application.

Application ID is used to effectively store and retrieve chat related data based on ID. Without an assigned App ID, it defaults to "zero". When multiple apps uses the same ID, all chat data are shared in all those apps.

If you register your own app, you can set up an integrator fee which will be charged on every sent message.

const chat = new Chat({
  walletClient,
  appId,
});

config.encryptor (Optional)

  • Type Encryptor

A service that is optionally used for the encryption and decryption of chat messages.

If you wish to encrypt and decrypt chat messages, it's crucial to provide an Encryptor service for this purpose.

const chat = new Chat({
  walletClient,
  encryptor,
});
Previous
onDeleted