A live, mainnet, zero-risk, free-to-play, multi-contract chess protocol running on Stacks where:
• STX = gas only • CHESS token = game economy • Funds are isolated • Logic is modular • Everything is extensible
This is your FULL MASTER SMART CONTRACT ARCHITECTURE (Mainnet + Free Economy Model) ♟️
┌────────────────────┐
│ router.clar │
│ (entry point) │
└─────────┬──────────┘
│
┌───────────────────────────┼────────────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ registry.clar │ │ escrow.clar │ │ logic.clar │
│ game storage │ │ token vault │ │ move engine │
└──────┬────────┘ └──────┬────────┘ └──────┬────────┘
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ timer.clar │ │ chess-token │ │ ranking.clar │
│ timeout sys │ │ SIP-010 FT │ │ elo stats │
└───────────────┘ └───────────────┘ └───────────────┘
Used only for: • Gas fees • Deployment
Never used for wagers.
Free in-game currency.
Used for: • Wagers • Rewards • Tournament pools • Ranking incentives
Minted freely during testing.
Zero financial risk.
This is the economic fuel.
• Mint tokens • Transfer tokens • Faucet function (optional) • Supply control
total-supply
owner
mint-enabled
Name: Chess Token
Symbol: CHESS
Decimals: 6
During dev:
mint-enabled = true
Production:
mint-enabled = false
This is the treasury chamber.
Only CHESS tokens.
• Lock wager tokens • Release tokens to winner • Refund tokens • Prevent double withdrawal
game-id → {
white-amount: uint
black-amount: uint
total: uint
claimed: bool
}
Uses:
ft-transfer?
Not:
stx-transfer?
This isolates real value risk.
This is the canonical source of truth.
• Create game • Assign players • Track status • Track whose turn • Track move count • Mark finished
game-id → {
white: principal
black: optional principal
wager: uint
status: uint
turn: principal
move-count: uint
created-at: uint
last-move-at: uint
}
0 = waiting
1 = active
2 = finished
3 = cancelled
The referee.
It does NOT validate chess rules.
Frontend validates legality.
On-chain logic enforces:
• Turn order • Move recording • Move counter • Resignation
(game-id, move-number) → {
player: principal
move: string-ascii
timestamp: uint
}
Prevents griefing.
• Validate inactivity • Allow timeout claim • Reset move timer
game-id → {
timeout-duration: uint
}
Timeout logic uses:
block-height
for deterministic timing.
Optional but powerful.
Tracks:
• Wins • Losses • Draws • Elo score
player → {
wins: uint
losses: uint
rating: uint
}
The only contract the frontend calls.
It coordinates everything.
It does NOT store state.
User → router.create-game
→ escrow.lock-tokens
→ registry.create-game
→ timer.initialize
User → router.join-game
→ escrow.lock-tokens
→ registry.assign-black
→ registry.activate
User → router.submit-move
→ logic.record-move
→ registry.update-turn
→ timer.reset
User → router.resign
→ logic.record-resignation
→ escrow.release
→ registry.finish
→ ranking.update
User → router.claim-timeout
→ timer.validate
→ escrow.release
→ registry.finish
→ ranking.update
escrow: • Cannot change game state
Registry: • Cannot release funds
Logic: • Cannot access funds
Router: • Cannot bypass validation
Token: • Cannot interfere with game logic
Each contract has single responsibility.
This prevents catastrophic exploits.
Deploy in this order:
1 chess-token.clar
2 escrow.clar
3 registry.clar
4 logic.clar
5 timer.clar
6 ranking.clar
7 router.clar
Router last because it references others.
Because token is free:
• Mint unlimited CHESS • Wager fake tokens • Only pay STX gas • Real blockchain execution • Real contract addresses • Real indexing
Financial risk = zero.
This architecture supports:
• Tournament contract • DAO governance • Betting pools • Spectator rewards • NFT match certificates • ChessFi staking • Leaderboard mining rewards
All without touching escrow core.
Your protocol becomes:
• Live mainnet • Free-to-play • Fully on-chain • Modular • Upgradeable via new versions • Economically isolated • Production scalable
This is not a demo.
This is infrastructure.