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

# Fees and app registration

How fees work in OCC v1: a base fee, an app owner fee, and app registration through an app ID.

{% hint style="warning" %}
**Status: Production-ready, stable.** OCC v1 is the 4thTech protocol for on-chain mail, chat and file transfer on any EVM chain. It is supported; no new features are planned. For agent-to-agent exchange, see OCC v2 ([AgentLink](https://wiki.4thtech.io/products/agentlink.md)).
{% endhint %}

Every exchange on OCC v1 has two kinds of cost: the network fee of the blockchain, and a protocol fee set per app.

## Parties

| Party          | Role                                                                                                 |
| -------------- | ---------------------------------------------------------------------------------------------------- |
| User           | Sends the exchange and pays the network fee and the app's required fee                               |
| App integrator | Registers an app (app ID) with the AppFeeManager contract and collects the app integrator fee for it |
| Protocol owner | The owner of the fee-collecting contract; collects the base fee                                      |

The original protocol-fees schematic links the base fee to Level-1 integrators and the app ("dApp owner") fee to Level-2 integrators ([Integration paths](https://wiki.4thtech.io/developers/integration-paths.md)); whether this still applies is to be confirmed.

## How it works

1. An integrator registers an app and receives an **app ID** through the AppFeeManager contract.
2. The app passes its app ID when it sends a mail or a chat message.
3. The Mail or Chat contract reports the fee required for that app ID (`getAppRequiredFee`); the SDK reads it and sends it with the exchange.
4. If the amount sent is too low, the contract rejects the exchange (`InsufficientFeeSent`). Otherwise it records the fee as two parts, a base fee and an app integrator fee (`FeesCollected`), and handles any excess as the contract defines.
5. The app integrator withdraws the app's collected fees (`withdrawAppFees`); the protocol owner withdraws the base fees (`withdrawOwnerFees`).

```mermaid
flowchart LR
    U["User wallet"] -- "network fee" --> Net["Blockchain"]
    U -- "required fee" --> C["Mail or Chat contract"]
    C --> Base["Base fee"]
    C --> Int["App integrator fee"]
    Base --> O["Protocol owner (withdrawOwnerFees)"]
    Int --> I["App integrator (withdrawAppFees)"]
```

*Figure: the required fee paid with an exchange is recorded as a base fee and an app integrator fee, each withdrawn by its party. Derived from the contract interface used by SDK 0.5.x.*

The exact split rules are defined in the contracts. The original schematic is the [protocol fees schematic](https://github.com/4thtech/static-assets/blob/main/image/4thTech-protocol-fees-schematic.svg).

{% hint style="info" %}
Fee amounts differ per network and per app, and can change. This page gives no amounts.
{% endhint %}
