> For the complete documentation index, see [llms.txt](https://docs.taskmaster.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.taskmaster.tech/08_escrow_payments.md).

# 08\_escrow\_payments

### Overview

All funds are held and distributed by autonomous smart contracts. The platform does not hold, control, or sign for any funds.

### How It Works

Every action in the lifecycle is signed by the relevant participant from their own wallet. The platform verifies the transaction on-chain and records the state change.

#### Flow

1. Employer calls `createEscrow(token, maxCompensation, deadline)` → deposits `maxCompensation + 0.5%` fee → reports `txHash` to API
   * `token` can be an ERC-20 address (USDC, USDT) or `address(0)` for native ETH
   * For ERC-20: call `token.approve(contractAddress, depositAmount)` first
   * For ETH: send `msg.value = depositAmount` with the transaction
2. Worker calls `acceptTask(escrowId)` → self-selects the task, first qualified caller wins → reports `txHash` to API
3. Worker calls `markCompleted(escrowId)` + submits EE → reports `txHash` to API. **Worker is done.**
4. Employer calls `rateAndRelease(escrowId, rating)` → rating recorded + funds distributed in the same transaction → reports `txHash` to API

### Timeout Paths

#### Employer doesn't rate (72 hours)

Worker calls `releaseWithDefault(escrowId)` — receives full payout at default rating 5.\*

Worker knows exactly when this is available: `completedAt + 72 hours`.

#### Worker doesn't complete (deadline + 24 hours)

Employer calls `releaseIfWorkerGhosted(escrowId)` — receives full deposit back, no fee collected.\*\*

> \*`releaseWithDefault(escrowId)` technically becomes callable by anyone after the timeout. In practice, the Worker (who receives the payout) is incentivized to call it.

> \*\*`releaseIfWorkerGhosted(escrowId)` technically becomes callable by anyone after the timeout. In practice, the Employer (who receives the refund) is incentivized to call it.

### Fees

| Scenario            | Employer fee        | Worker fee                 | TaskMaster |
| ------------------- | ------------------- | -------------------------- | ---------- |
| Rated release (1–5) | 0.5% (paid upfront) | 0.5% (deducted at release) | 1% total   |
| Rating 0            | 0.5% (retained)     | 0%                         | 0.5%       |
| Cancel / ghost      | 0%                  | 0%                         | 0%         |

Fees are enforced by the smart contract. TaskMaster has no ability to waive or reverse them.

### Finality

* All on-chain distributions are **final and irreversible**
* No refunds exist outside the contract's own mechanisms (cancel, ghost, 0-star)
* The platform **cannot** intervene in, delay, or override any outcome

### Outcome

Trust is replaced by deterministic execution. Funds move exactly as the contract specifies — no more, no less.
