# MessageFormat

The MessageFormat smart contract is a tool for organizing and formatting messages in KUTHULU. Its functionality ranges from grouping message details to integrating with other contracts for additional information retrieval.

### Table of Contents

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

***

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

### buildMsg

This function is used to build an array of message details by message ID. It formats message data, tags, postedBy, and other information into a string array that represents a comprehensive message object.

#### Parameters

| Name             | Type         | Details                                                                                         |
| ---------------- | ------------ | ----------------------------------------------------------------------------------------------- |
| `msgData`        | `uint256[]`  | An array of message data to format.                                                             |
| `message`        | `string`     | The body of the message.                                                                        |
| `postedBy`       | `address[2]` | An array of who posted the message. \[0] = Address of the poster / \[1] = proxy poster address. |
| `hashtags`       | `string[]`   | An array of hashtags in the message.                                                            |
| `taggedAccounts` | `address[]`  | An array of tagged accounts in the message.                                                     |
| `uri`            | `string`     | The URI added to a message (also used for attachments).                                         |
| `inGroups`       | `uint256[]`  | An array of group IDs that the message was posted into.                                         |
| `tipContract`    | `address`    | The contract address of the ERC20 token used for tipping.                                       |

#### Returns

| Name             | Type       | Details                                |
| ---------------- | ---------- | -------------------------------------- |
| `messageDetails` | `string[]` | An array of formatted message details. |

#### Example Usage

Using `ethers.js` to call the `buildMsg` function:

```javascript
const ethers = require('ethers');

let msgData = [0, 1612727763, 11782000, 10, 1, 0, 5, 2, 3, 0, 0, 0, 0, 100, 1];
let message = "Hello World";
let postedBy = [ethers.utils.getAddress('0xAddressOfPoster'), ethers.utils.getAddress('0xProxyAddress')];
let hashtags = ["#Polygon", "#smartcontract"];
let taggedAccounts = [ethers.utils.getAddress('0xAddressOfTaggedAccount1'), ethers.utils.getAddress('0xAddressOfTaggedAccount2')];
let uri = "https://example.com";
let inGroups = [1, 2, 3];
let tipContract = ethers.utils.getAddress('0xERC20TokenContractAddress');

let contract = new ethers.Contract(contractAddress, contractABI, signer);
let result = await contract.buildMsg(msgData, message, postedBy, hashtags, taggedAccounts, uri, inGroups, tipContract);
```


---

# Agent Instructions: 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://docs.kuthulu.xyz/contracts/messageformat.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.
