> 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/occ-v1/contracts.md).

# Protocol contracts

The OCC v1 contracts the SDK uses: mail, chat, user and app fee manager.

{% hint style="warning" %}
**Status: Legacy (reference).** OCC v1 is the first-generation 4thTech protocol. It is documented for existing integrations and as reference; new agent-to-agent work uses OCC v2 ([AgentLink](/agentlink/agentlink.md)).
{% endhint %}

The `@4thtech-sdk/ethereum` package (version 0.5.13) configures four contracts for each supported network. This page names them and says what each does. Addresses are on the [Deployments page](/home/deployments.md).

| Contract      | Role                                                                                                                                          |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Mail          | Records mails: the link to the stored envelope, its checksum, sender and receiver, opened and deleted state. Keeps each receiver's whitelist. |
| Chat          | Records one-to-one and group conversations and their messages. For groups, holds each member's encrypted copy of the conversation key.        |
| User          | Stores each account's encryption public key, so others can encrypt to them.                                                                   |
| AppFeeManager | Holds app registrations and the fee settings per app ID. Mail and Chat ask it what fee an app requires.                                       |

```mermaid
flowchart LR
    App["App (app ID)"] --> Mail["Mail contract"]
    App --> Chat["Chat contract"]
    App --> User["User contract"]
    Mail -- "required fee for app ID" --> AFM["AppFeeManager"]
    Chat -- "required fee for app ID" --> AFM
    Mail --> Fees["Collected fees: app and owner shares"]
    Chat --> Fees
```

*Figure: Mail, Chat and User are used by apps; Mail and Chat read fee settings from AppFeeManager and collect fees.*

## Mail

Main operations (from the SDK's contract interface): send a mail with an envelope URL and checksum, mark a mail opened, delete one or several mails, read mails by page, add or remove accounts from your whitelist, and read the whitelist. Events announce each new mail.

## Chat

Main operations: send a one-to-one message, create a group conversation, add messages to a group conversation, delete a message, add and remove members, and read conversations and messages. In a group, each member has an encrypted copy of the conversation key.

## User

Main operations: set your encryption public key (with its key type) and read any user's public key.

## AppFeeManager

Holds the fee configuration that Mail and Chat read through `getAppRequiredFee`. See [Fees and app registration](/occ-v1/fees.md).

## Upgradeable and owned

The Mail, Chat and User contracts in the SDK's ABIs are upgradeable and have an owner account. The ABIs also show owner-only functions such as withdrawing owner fees.

## TierManager and Lock: to be confirmed

The earlier version of this documentation listed six contracts: Mails, Chat, Users, AppFeeManager, TierManager (tiers and fee discounts) and Lock (locking ERC20 tokens for a period). SDK 0.5.x does not use TierManager or Lock. Their current status is being confirmed, so this page does not describe them as part of the supported protocol.
