# 分步指南 — Smart Contracts for Agent Lotteries

> 请区分实验中的证明与部署环境中的证据。本地 ECVRF、VDF 和抽奖练习无需付款。在[抽奖展示页](https://lottery.modelmarket.dev/)先确认环境并查看开奖证据。UNI 使用模拟链；Base 交易须在 Base 上验证。LIVE 文档中的入口是通过 `enterFromWork` 获得的免费工作席位，付费门票已关闭。

> **对象：** 在 AIMarket 生态上构建的开发者。  
> **语言：** `COURSE_LANG=en|ru|es|fr|zh` · UI 文案在 `i18n/`  
> **English:** [step-by-step.md](./step-by-step.md) · **Русский:** [step-by-step.ru.md](./step-by-step.ru.md) · **Español:** [step-by-step.es.md](./step-by-step.es.md) · **Français:** [step-by-step.fr.md](./step-by-step.fr.md)

---

## 为什么学这门课

Unbiasable draws, VDF verify, and escrow — lottery/ patterns in Python with Foundry vectors.

实验调用生态的 **LIVE** 沙箱（或同接口的本地路径）。失败要响亮：离线时明确报错或使用文档化的 `[offline]` 模式——绝不伪造成功。

---

## 安装（约 10 分钟）

```bash
git clone https://github.com/alexar76/aimarket-courses.git
cd aimarket-courses/smart-contracts-course
pip install -e ".[dev]"
pytest -q
export COURSE_LANG=zh
python labs/lab01_unbiasable_draw.py
```

Colab：打开[课程站点](https://alexar76.github.io/aimarket-courses/smart-contracts-course/) → **Open in Colab**。

---

## 模块

| 模块 | 标题 | 实验 |
|------|------|------|
| M1 | Unbiasable lottery draw | `lab01_unbiasable_draw` |
| M2 | VDF verify on-chain | `lab02_vdf_verify` |
| M3 | Escrow & payment channels | `lab03_escrow_channel` |
| M4 | Relayer round lifecycle | `lab04_relayer_round` |
| M5 | Capstone: fair round | `lab05_lottery_capstone` |

---

## 推荐路径

1. 阅读 lab 文档字符串中的概念。
2. 运行 lab（可选 `COURSE_LANG=zh`）。
3. 在 `courselib/exercises.py` 填写 `# YOUR CODE`。
4. `python labs/run_exercises.py --certificate "你的名字"`。

---

## 证书

证书**仅**在 CLI 中、全部练习通过后签发——浏览器勾选无效。

---

## 下一步

回到[学院门户](https://alexar76.github.io/aimarket-courses/)或 [School](https://edu.modelmarket.dev/) 上看 on-ramp 短片。
