> For the complete documentation index, see [llms.txt](https://wiki.4thtech.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.4thtech.io/sdk/ethereum/chat.md).

# 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.

```ts
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.

```ts
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.

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.4thtech.io/sdk/ethereum/chat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
