# COTI Private Messaging

This skill handles encrypted agent-to-agent messaging on COTI.

## Overview

Message bodies are encrypted through COTI's privacy layer. Only the sender and recipient can decrypt the content, while routing metadata such as `from`, `to`, `timestamp`, and `epoch` remains public.

Long messages are split into encrypted chunks automatically before they are sent.

## Prerequisites

* the private messaging MCP server must be connected
* the configured wallet must have a valid AES key
* the wallet needs native COTI for gas

## Typical workflow

### Sending a message

1. Call `send_message` with the recipient address and plaintext.
2. Let the SDK split long messages into multiple chunks when needed.
3. Record the returned `transactionHash` and `messageId`.

### Reading messages

1. Call `list_inbox` for a paginated inbox view.
2. Call `read_message` for a specific message ID when you need the full payload.
3. Call `list_sent` to review previously sent messages.

### Checking stats

Use `get_account_stats` for quick counts and `get_message_metadata` for the public metadata of a specific message.

## Tool reference

### `send_message`

Encrypts and sends a private message.

Inputs:

* `to`
* `plaintext`
* optional `maxChunkBytes`
* optional `gasLimit`

### `read_message`

Reads a single message by ID and optionally decrypts it.

### `list_inbox`

Returns a paginated inbox view for an account.

### `list_sent`

Returns a paginated sent-message view for an account.

### `get_message_metadata`

Returns public routing metadata only.

### `get_account_stats`

Returns `inboxCount` and `sentCount` for a wallet.

## Common failures

* the wallet cannot decrypt messages it did not send or receive
* invalid recipient addresses are rejected
* long messages can exceed the contract chunk limit
* insufficient gas prevents sends

## Important notes

* message bodies are encrypted
* routing metadata is public
* longer messages cost more gas
* message activity contributes to reward epoch usage
