> 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/onconversationremoved.md).

# onConversationRemoved

Sets up a listener for when a message is deleted from a conversation.

### Usage

```ts
const creatorAddress = '0x...';
const conversationHash = '0x...';

// Listen to all conversations removed by the specified sender
chat.onConversationRemoved(creatorAddress, null, (sender, conversationHash) => {
  console.log(sender);
  console.log(conversationHash);
});

// Listen to a specific conversation removed by any sender
chat.onConversationRemoved(null, conversationHash, (sender, conversationHash) => {
  console.log(sender);
  console.log(conversationHash);
});

// Listen to any conversation removal events
chat.onConversationRemoved(null, null, (sender, conversationHash) => {
  console.log(sender);
  console.log(conversationHash);
});
```

#### Stop watching

```ts
// Listen to any conversation removal events
const stopWatching = chat.onConversationRemoved(null, null, (sender, conversationHash) => {
  console.log(sender);
  console.log(conversationHash);
});

// ... Later, to stop watching for the events
stopWatching();
```

### Returns

`UnwatchFn`

A function that can be invoked to stop watching for new event logs.

### Parameters

#### sender

* **Type** `Address | null`

The conversation creator's address who deleted the conversation. If set to null, it listens for conversations removed by any sender.

#### conversationHash

* **Type** `ConversationHash | null`

The hash of the target conversation that got removed. If set to null, it listens for the removal of any conversation.

#### callback

* **Type** `(sender: Address, conversationHash: ConversationHash) => void`

A callback function that will be executed when a conversation removal event is detected. This callback is passed two arguments:

* `sender`: The creator's address who removed the conversation.
* `conversationHash`: The hash of the removed conversation.


---

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