---
title: Introduction
---

# AMP — Verifiable Tournament Engine

AMP is a trustless tournament engine for competitive gaming on Avalanche. An organizer funds a **sponsor prize pool**, the bracket runs off-chain, and winners **pull-claim** their payout from an on-chain escrow (`AMPTournamentCup`). Every result is EIP-712 attested; every payout is a public Avalanche transaction.

> The full documentation is being rewritten for the tournament-engine architecture. The legacy docs (which described the removed Cap'n Proto matchmaking stack) are preserved as `*.mdx.old` and are not rendered. This page is the current source of truth.

---

## The product (4 components)

| Component | Language | Role |
|:---|:---|:---|
| `web/` | TypeScript / Next.js | UI (`/setup`, `/manage`, `/play`, `/cup`, `/claim`) + JSON API + bracket engine + Postgres client |
| `relayer/` | Rust | Isolated custodial relayer — the **only** process holding the funded key; drains a Postgres job queue, signs EIP-712, submits on-chain |
| `contracts/` | Solidity | `AMPTournamentCup` — sponsor-funded prize escrow. The security boundary |
| `migrations/` | SQL | Postgres schema (tournaments, brackets, relayer job queue) |

The bracket engine is a single TypeScript implementation in `web/src/lib/engine/` (single-elimination, round-robin, Swiss). The funded key is isolated in the Rust relayer; the web app has zero custody authority.

---

## Live contract (Fuji testnet)

| Contract | Address | Role |
|:---|:---|:---|
| `AMPTournamentCup` | [`0x7c743c1c9ae3e7a65d030098f2249b7787d66dff`](https://testnet.snowtrace.io/address/0x7c743c1c9ae3e7a65d030098f2249b7787d66dff) | The tournament product: sponsor-funded pools, EIP-712 attested finalization, winner pull-claims |
| `AMPRegistry` / `AMPSettlement` / `AMPTimelock` | [`0x27E02…`](https://testnet.snowtrace.io/address/0x27E02ebA98D2A50Cd1079b0a611320b05A278005) … | **Legacy** 1v1 wagering escrow — deployed, governance-finalized, not used by the tournament product |

Deployment manifest + a verified end-to-end demo: [`contracts/deployment-fuji-tournament.json`](https://github.com/BradMyrick/Avalanche-Matchmaking-Protocol/blob/main/contracts/deployment-fuji-tournament.json).

---

## How it fits together

```
Browser (Next.js)        JSON over HTTPS          On-chain (Fuji)
┌───────────────┐   ┌─────────────────────┐   ┌────────────────────┐
│ /setup        │──▶│ /api/tournament/*   │   │ AMPTournamentCup   │
│ /manage /play │   │ /api/paypal/*       │◀──│  (escrow + EIP-712 │
│ /cup  /claim  │   │ Postgres queue      │   │   finalize + claim)│
└───────────────┘   └─────────┬───────────┘   └────────────────────┘
                              │ enqueue jobs           ▲
                              ▼                        │ sign + submit
                    ┌─────────────────────┐   ┌────────────────────┐
                    │ Postgres            │◀──│ relayer/ (Rust)    │
                    │ tournaments/brackets│   │ sole funded-key    │
                    │ relayer_jobs        │   │ holder             │
                    └─────────────────────┘   └────────────────────┘
```

## Run it

> **Database:** use Neon Postgres, and set `DATABASE_URL` to the **pooled** connection string (the one with `-pooler` in the hostname) — the web runs on Vercel serverless and needs the pooled endpoint.

```bash
# Web (requires DATABASE_URL — Neon, pooled)
cd web && npm install && npm run dev

# Relayer — the custody process (requires DATABASE_URL + AMP_RELAYER_KEY)
# Run as a persistent daemon (Fly.io / Railway / Render / VPS), NOT on Vercel.
cd relayer && cargo run --release

# Contracts
cd contracts && forge test -vvv
```

See the [root README](https://github.com/BradMyrick/Avalanche-Matchmaking-Protocol/blob/main/README.md) for the full architecture, security model, and the security-remediation status.
