# Tagged

The Tagged Smart Contract allows managing and querying tagged messages. Tagged messages are grouped by user or group addresses.

### Table of Contents

1. [Events](#events)
2. [Public Functions](#public-functions)

***

## <mark style="color:purple;">Events</mark>

These are the events that are emitted by the contract functions.

### **logAddTag**

This event is emitted when a new tag is added to a message.

| Variable      | Description                        |
| ------------- | ---------------------------------- |
| msgID         | The ID of the message.             |
| taggedAccount | The address of the tagged account. |

### **logRemoveTag**

This event is emitted when a tag is removed from a message.

| Variable        | Description                          |
| --------------- | ------------------------------------ |
| msgID           | The ID of the message.               |
| untaggedAccount | The address of the untagged account. |
| ---             |                                      |

## <mark style="color:purple;">Public Functions</mark>

### **GetTaggedMessageIDs**

This function can be used to get a list of all message IDs that a particular user or group is tagged in, starting from a specific message ID. It returns an array of message IDs. If the address does not exist or if there are no tagged messages, it returns an empty array.

| Input      | Description                                                 |
| ---------- | ----------------------------------------------------------- |
| usrAddress | The address of a user or group to retrieve the details for. |
| startFrom  | The number to start getting records from.                   |

| Output     | Description             |
| ---------- | ----------------------- |
| uint256\[] | An array of message IDs |

**Example:**

```javascript
const userAddress = "0x1234..."; // User's address
const startFrom = 10; // Start from message ID 10

const contract = new ethers.Contract(contractAddress, abi, signer);
const messageIDs = await contract.getTaggedMsgIDs(userAddress, startFrom);

console.log(messageIDs); // An array of message IDs
```
