# Build Escrow Contract

> Compile Aztec Noir escrow contracts from source and generate TypeScript bindings. Use when the user asks to build, verify compilation, or after modifying contract source code.

- Skill: `aztecprotocol/build-escrow-contract` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add aztecprotocol/build-escrow-contract`
- Raw SKILL.md: https://api.skillmd.com/api/skills/aztecprotocol/build-escrow-contract/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: aztecprotocol (https://skillmd.com/u/aztecprotocol)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/aztecprotocol/build-escrow-contract

---


# Build Escrow Contracts

Compile the generated Aztec escrow contract and refresh TypeScript bindings.

## Prerequisites

- Aztec CLI `5.1.0`
- Bun

Commands assume `PROJECT_DIR=aztec-otc-desk` unless already inside the generated project.

## Build Flow

Token artifact is built by root `postinstall` from `deps/aztec-standards`. Escrow artifact is rebuilt from `packages/contracts`.

```bash
cd "${PROJECT_DIR:-aztec-otc-desk}/packages/contracts"
bun run build
```

This runs:

```bash
aztec compile
aztec codegen target --outdir ts/src/artifacts/escrow -f
bun run scripts/add_artifacts.ts
```

The generated `add_artifacts.ts` copies `target/otc_escrow-OTCEscrow.json` into `ts/src/artifacts/escrow/OTCEscrow.json` and rewrites the generated JSON import to `./OTCEscrow.json`.

To rebuild the token artifact manually from the project root:

```bash
bun run scripts/token.ts
bun run scripts/token.ts --skip-submodules
```

## Source Map

- `packages/contracts/src/main.nr` - escrow contract.
- `packages/contracts/src/types/config_note.nr` - immutable config note.
- `packages/contracts/src/types/state_note.nr` - mutable lifecycle state.
- `packages/contracts/ts/src/artifacts/` - generated TS bindings and JSON artifacts.
- `packages/contracts/ts/src/` - SDK helpers: contract calls, manifest, fees, precision utilities.

If a build failure requires Noir, note, event, token, lifecycle, or SDK behavior changes, switch to `write-escrow-contract`.

## Tests

Generated projects use TypeScript/Bun localnet tests only. Keep Aztec.nr/TXE scripts out of `package.json`.

The contracts package test script should be:

```json
"test": "bun test --preload ./ts/test/setup.ts --timeout 300000 ./ts/test/escrow.test.ts"
```

The preload shim provides `expect.addEqualityTesters` for Aztec JS packages, and the explicit test file prevents Bun from discovering `deps/aztec-standards` tests. Localnet tests take minutes; run targeted `bun test ... -t "<name>"` while iterating, then one full `bun run test`.

