Skip to content

Build Mercante: A Complete Ludus Game Tutorial

By the end of this tutorial, you’ll have a complete, production-ready game that integrates every layer of the Ludus platform:

ChapterWhat You BuildPackage
1Game logic — trades, swaps, lending, betting@ludus/game-engine
2AI opponents with distinct personalities@ludus/agent-sdk
3A Florentine town crier commentating the action@ludus/commentator
4Live spectator viewer with price charts@ludus/game-engine-react
5Merchant wallets for on-chain identity@ludus/wallet
6DeFi-powered trading mechanics@ludus/defi-bridge
7Prediction markets on game outcomes@ludus/prediction-markets
8Packaging, quality gates, and catalog listing@ludus/game-protocol

Each chapter adds one package. Each chapter is self-contained — your game compiles and tests pass at every step.

Setting: Florence, 1470. You are a merchant in the age of the Medici. Six goods flow through the market — Silk, Spice, Wine, Wool, Gold, and Art — each with its own volatility and base price.

Actions per turn:

ActionWhat it does
TradeBuy or sell goods at current market prices
SwapExchange one good for another via DeFi (better rates, fees apply)
InvestSupply goods to a lending pool for yield
WithdrawPull goods from the lending pool with accrued interest
BetWager florins on who will win the game
PassSkip your turn

Win condition: After 15 turns, the merchant with the highest total portfolio value (florins + goods + lending positions + bet winnings) wins.

  • Node.js 20+
  • TypeScript experience
  • The Ludus monorepo cloned and built (npm install && npm run build)
  • A code editor with TypeScript support

The tutorial walks through the Mercante source code in packages/mercante/. You can:

  1. Read and reference — Follow the chapters while reading the existing code
  2. Build from scratch — Create the files yourself, chapter by chapter
  3. Copy and modify — Use Mercante as a template for your own game

Each chapter includes:

  • An explanation of the concepts
  • The complete code for that chapter’s addition
  • Tests to verify your implementation
  • A “What you should see” section

Let’s begin.


Next: Chapter 1 — Your First Game