A Nintendo-style 8-bit adventure game that showcases Formance Ledger features through gameplay.
"The Evil Auditor tried to rewrite the Ledger. But the Hash Chain exposed his fraud. Only the Ledger Knight can verify the truth and restore order."
Option A โ Standalone (no dependencies)
# Just open it in a browser
open index.htmlOption B โ With a local dev server
npx serve . -p 3000
# Open http://localhost:3000Option C โ Connected to a real Formance Ledger
# Start a Formance Ledger on port 3068
docker run -p 3068:3068 ghcr.io/formancehq/ledger:latest serve
# Then open the game โ it auto-connects and creates a ledger in the "ledgerquest" bucket
open index.htmlWhen connected to a real ledger, the HUD shows a green LIVE indicator and every in-game transaction is mirrored as a real Formance Ledger transaction you can query via the API. Each game session creates a unique ledger named ledgerquest-<timestamp> inside the ledgerquest bucket:
# List ledgers to find the current game session
curl http://localhost:3068/v2/ | jq '.cursor.data[] | .name'
# โ "ledgerquest-1773413892220"
# Use the ledger name from above in all queries:
LEDGER="ledgerquest-1773413892220"
# See all game transactions
curl http://localhost:3068/v2/$LEDGER/transactions | jq
# Check the hero's account
curl http://localhost:3068/v2/$LEDGER/accounts/hero:wallet | jq
# Check an enemy's account
curl http://localhost:3068/v2/$LEDGER/accounts/courtyard:s1 | jq| Key | Action |
|---|---|
Arrow Keys / WASD |
Move |
Space |
Attack (sword swing) |
E |
Interact (talk to NPCs, open chests) |
F |
Throw Fire Bomb (if carrying bombs) |
T |
Time Rewind (in Temple, requires Temporal Insight) |
E (Holy Ledger) |
Open the Sacred Ledger terminal (requires all 3 Integrity Sigils) |
Shift (hold) |
Fast-forward dialog (4ร speed, auto-advance) |
M |
Mute / Unmute music (SFX stay on) |
ESC |
Pause / Resume |
Enter |
Start game / advance dialog |
The Kingdom of Formance runs on a magical ledger that records every gold coin flowing through the realm. The Evil Auditor tried to falsify the kingdom's records, but the Hash Chain detected every lie โ and the Ledger sealed itself for verification. Three Integrity Sigils โ proof fragments scattered across the Mint โ must be recovered to verify the chain's integrity. You play as the Ledger Knight, tasked with fighting through enemies, collecting sigils, freeing the imprisoned Time Monk, and proving the truth of every transaction.
Your journey begins in the Hall of Origins, where the Ledger Sage teaches you the way of the ledger and a Farmer begs you to catch his runaway Golden Goose. In the Courtyard, you'll battle slimes, chase the goose for golden eggs, and trade with the Blacksmith โ whose forge runs on Numscript scrolls, the ledger's scripting language. Each purchase triggers a treasure chest pop animation as your items are forged.
Deeper in, the Wizard of Worlds reveals the power of the world account โ an infinite wellspring from which gold is born and to which it returns. The Ghost Twins (Debit & Credit) perform a live multi-posting transaction โ your gold flows through three accounts in a single atomic scroll. The mischievous Refund Imp offers to bulk-revert every coin monsters ever stole from youโฆ for a price.
Below lies the Forgotten Crypt, where a Ghost Banker teaches the lesson of INSUFFICIENT_FUNDS โ what happens when you try to spend more than you have. The Ledger rejects the transaction entirely: no partial moves, no negative balances. Beyond the Wizard's sealed gate, the Temple of Time awaits โ where Temporal Wraiths guard an imprisoned Time Monk who holds the secret of bi-temporality: the power to record transactions with past effective dates. Free him, and he grants you the ability to see through time itself โ the Ledger replays all that followed from the new event.
Collect all three Integrity Sigils to unseal the Holy Ledger โ an interactive terminal that lets you browse every account, transaction, and chain block in the kingdom โ then face the Evil Auditor in the Treasury to verify the ledger's integrity once and for all.
โโ
โโโโ
โโโโโโ hero:wallet
โโโโโโ โโโโโโโโโโโ
โโโโ GOLD: ???
โโโโโโ SIGIL: 0/3
โ โโ โ
โ โโ โ
- Account:
hero:wallet - The hero whose every action is recorded on-chain. Your gold balance, input/output volumes, and transaction history are displayed on the HUD in real-time. When carrying SHIELD, a blue shield overlay appears on the sprite.
- Location: Hall of Origins โ Role: Tutorial NPC
- Explains the basics: transactions, accounts, and how the ledger tracks everything. Hints at the three Integrity Sigils and the Temple of Time.
- Location: Hall of Origins โ Role: Quest giver
- His Golden Goose has escaped to the Courtyard! Catch it for a golden egg.
- Location: The Courtyard (roaming) โ Role: Chase mini-game
- A fast-moving golden goose that flees when you get close. Catch it to receive a golden egg (GOLD from
world). Gets faster each time you catch it.
- Location: The Courtyard โ Role: Lore NPC
- A traveler who has heard of the Temple of Time and the imprisoned monk.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ THE BLACKSMITH'S FORGE โ
โ โ
โ ๐ก๏ธ Shield Pack (3) .... 30G โ
โ ๐ฃ Fire Bombs (5) .... 40G โ
โ ๐ Swirl Scroll ..... 50G โ
โ โ
โ send [GOLD 30] โ
โ (source = @hero:wallet โ
โ destination = @shop:forge) โ
โ send [SHIELD 3] โ
โ (source = @shop:forge โ
โ destination = @hero:wallet) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Account:
shop:forgeโ Location: The Courtyard - Every purchase executes a Numscript scroll โ Formance Ledger's domain-specific language for multi-asset atomic transfers. The dialog shows actual Numscript code: multiple
sendblocks in one script, each moving a different asset, executed atomically.
- Account:
worldโ Location: Wizard's Chamber - In Formance Ledger, the
worldaccount represents external funds entering the system. Any transaction fromworldcreates money; any transaction toworlddestroys it. The wizard gives you 100 GOLD โ watch the transaction receipt float up!
- Location: Wizard's Chamber
- Two spectral figures (Debit & Credit) who perform a live multi-posting transaction: Debit takes 1 GOLD from you, passes it to Credit, and Credit gives you back 2 GOLD โ three accounts, three movements, one atomic scroll. They demonstrate that a single transaction can chain multiple sourceโdestination postings atomically.
- Location: Wizard's Chamber
- A mischievous green imp who can reverse all damage-penalty transactions at once โ a bulk revert. Every coin monsters stole from you is returned in one spell. Costs HP with escalating price: 1 HP first use, 2 HP second, 3 HP third, etc.
- Account:
ghost:vaultโ Location: The Forgotten Crypt - A spectral banker who tried to spend more gold than they had. The Ledger refused the transaction โ
INSUFFICIENT_FUNDS. Now they haunt the crypt, doomed to replay their failed transaction for eternity. On first encounter, the ghost attempts to send 1,000 GOLD (with only 5 in their vault) โ you see the red TX REJECTED animation. Then they send what they actually have: 5 GOLD. The lesson: the Ledger only moves what truly exists in the source account.
โโโโ Each slime has its own
โโโโโโ ledger account:
โโโโโโ courtyard:s1
โโโโโโ courtyard:s2
โโโโ courtyard:s3
Green Blue Red Orange
10G 15G 25G 20G
- Accounts:
courtyard:s1,courtyard:s2,courtyard:s3, etc. - When entering a room for the first time, all enemies are funded in a single multi-posting mint transaction. When you defeat a slime, an atomic transaction transfers their entire gold balance to your wallet.
- Location: Temple of Time โ Accounts:
temple:tw1,temple:cb1, etc. - Ghostly purple wraiths and armored cyan beetles that guard the Temple. Defeating all of them frees the Time Monk from his chains.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Every deed has TWO moments: โ
โ โ
โ ๐ insertion date โ
โ when it was WRITTEN โ
โ โ
โ โฐ effective date โ
โ when it truly HAPPENED โ
โ โ
โ A deed can be written TODAY... โ
โ ...yet speak of something that โ
โ happened YESTERDAY. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Location: Temple of Time (imprisoned)
- Once freed, he teaches you about bi-temporality: every deed has two moments โ when it was written (insertion date) and when it truly happened (effective date). Grants the Temporal Insight ability โ press
Tto create a transaction with a past effective date. The Ledger replays all that followed from the new event, recomputingeffectiveVolumes.
โโโ
โโโโโ treasury:boss
โโโโโโโ โโโโโโโโโโโโโ
โโโโโโโ HP: 15
โโโโโโโ GOLD: 100
โโโโโ
- Account:
treasury:bossโ Location: The Treasury - A crowned dark-red slime boss who tried to rewrite the kingdom's transactions but was caught by the Hash Chain. Defeating it triggers the victory screen โ "LEDGER INTEGRITY VERIFIED!" โ with a full Ledger Report showing your final balance, total transactions, Integrity Sigils, and temporal insight status.
The game takes place in a single bucket called the-mint, with 6 connected rooms:
โโโโโโโโโโโโโ
โ TREASURY โ
โ (boss) โ
โ ๐ seal โ
โโโโโโโฌโโโโโโ
โ
โโโโโโโโโโโโโโ โโโโโโโโโโโโโ โโดโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ HALL OF โโโโค COURTYARD โโโโค WIZARD'S โโโโค TEMPLE OF โ
โ ORIGINS โ โ โ โ CHAMBER โ โ TIME โ
โ (start) โ โ โ๏ธ forge โ โ ๐ฎ world โ โ โณ monk โ
โโโโโโโโโโโโโโ โโโโโโโโโโโโโ โโฌโโโโโโโโโโโ โ ๐ ledger โ
โ โโโโโโโโโโโโโโโโ
โโโโโโโดโโโโโโ
โ FORGOTTEN โ
โ CRYPT โ
โโโโโโโโโโโโโ
- Stone floor with red carpet. Ledger Sage, Farmer NPC, Integrity Sigil #1.
- Safe starting room. Talk to the Sage to learn the basics.
- Grass + stone paths + water + bridges. 3 slime enemies, Golden Goose, Wandering Pilgrim, Blacksmith Grindak, Integrity Sigil #2.
- Your first combat zone. Defeat slimes, buy shields & bombs, chase the Goose!
- Wood floor + red carpet. Wizard of Worlds, Ghost Twins, Refund Imp, Integrity Sigil #3.
- The path north to the Treasury is sealed โ collect all three Integrity Sigils to break through.
- Dark stone floor. 3 slimes, 2 beetles, Ghost Banker NPC, 2 treasure chests, heart pickup.
- A dark underground crypt. The Ghost Banker teaches INSUFFICIENT_FUNDS protection. Fight enemies and loot chests before facing the boss.
- Stone floor with gold piles and corruption vents. 2 red slimes, 1 orange slime, The Evil Auditor boss.
- The boss arena. Defeat all enemies and the Evil Auditor to win.
- Marble floor + stained glass. 3 Temporal Wraiths, 2 Chrono Beetles, imprisoned Time Monk, Holy Ledger.
- Defeat all enemies to free the Monk. Use
Tfor backdated transactions. Open the Holy Ledger withEonce all 3 shards are collected.
Every game mechanic maps to a real Formance Ledger concept:
| Game Mechanic | Ledger Feature | How It's Shown |
|---|---|---|
| ๐ฐ Collecting gold | Transactions with postings | Every coin pickup creates a { source, destination, asset, amount } posting |
| ๐ HUD balance | Account balances | Real-time display of hero:wallet balance |
| ๐ in/out volumes | Account volumes | HUD shows cumulative in: and out: for GOLD |
| ๐ข Enemy accounts | Multi-account system | Each enemy has its own account; room entry mints GOLD to all enemies in one multi-posting TX |
๐ฎ world wizard |
The world account |
Special account with infinite balance for fund creation |
| ๐งพ TX receipts | Transaction records | Floating receipts show TX ID and amount |
| ๐ LOG block counter | Append-only LOG (hash chain) | LOG:N in HUD grows with each TX |
| ๐ฆ Bucket label | Bucket isolation | HUD shows current bucket (the-mint) |
| ๐ท๏ธ Room accounts | Hierarchical addresses | Addresses like mint:courtyard, courtyard:s1 |
| ๐ฆ Chest opening | TX from world |
Chests create world โ hero:wallet transactions |
| โ๏ธ Enemy defeat | Atomic transfers | Enemy's full balance atomically transferred in one TX |
| ๐ป Ghost Twins | Multi-posting TX | Single TX with three postings: heroโdebitโcreditโhero, 3 accounts in 1 scroll |
| ๐ Refund Imp | Bulk revert | All damage-penalty TXs reversed in one ritual |
| โณ Time Rewind | Backdated transactions | Creates a TX with a past timestamp; response shows effectiveVolumes |
| ๐ท Integrity Sigils | SHARD asset | Verification proof fragments tracked alongside GOLD |
| ๐ Ghost Banker | INSUFFICIENT_FUNDS | Failed TX demo: source account can't go below zero |
| โ๏ธ Blacksmith shop | Numscript DSL | Purchase dialog shows send blocks for multi-asset atomic transfers |
| ๐ก๏ธ Shield item | Multi-asset accounts | SHIELD asset consumed on damage via hero โ world TX |
| ๐ฃ Fire Bombs | Asset consumption | BOMB asset tracked on ledger, each throw creates TX |
| ๐ Swirl Scroll | Asset-gated abilities | SWIRL asset unlocks combo ability |
| ๐ Holy Ledger | Account/TX browsing | Interactive terminal to browse accounts, transactions, and chain integrity |
| ๐ Boss victory | Ledger report | Final screen shows balance, volumes, shards, temporal insight |
When a Formance Ledger is running on localhost:3068, the game:
- Creates a
ledgerquest-<timestamp>ledger in theledgerquestbucket automatically - Mirrors every in-game transaction to the real API (
POST /v2/ledgerquest-<timestamp>/transactions) - Uses
force: trueforworldtransactions (infinite source) - Sends backdated transactions with
timestampfor bi-temporality (T key) - Shows a green LIVE dot in the HUD
- Maintains a local simulation as the gameplay source of truth (API failures don't break the game)
You can query the real ledger during or after gameplay to see the full transaction history, account balances, and volumes โ exactly as they would appear in a production financial system.
index.html (single file, ~5600 lines)
โโโ NES-inspired palette (custom dark theme, 20+ colors)
โโโ Pixel art sprite system (Link-style 16x16 sprites, 4 directions x 2 frames)
โโโ Simulated ledger engine (accounts, transactions, hash chain)
โโโ Real Ledger API client (fetch-based, fire-and-forget sync)
โโโ Web Audio music engine (5 themes: adventure, boss, temple, wizard, title)
โโโ Particle system (hit effects, gold sparkles, death explosions)
โโโ Dialog system (typewriter text, multi-line word wrap, choices, Shift fast-forward)
โโโ Tile-based room renderer (9 tile types including marble, stained glass)
โโโ Entity system (player, enemies, NPCs, items, Golden Goose AI)
โโโ Combat system (sword hitbox, knockback, damage, HP bars, power-ups, shield overlay, swirl AoE)
โโโ Bomb projectile system (throw, flight, AoE explosion, asset consumption)
โโโ Blacksmith shop system (Numscript DSL showcase, multi-asset atomic purchases: shields, bombs, swirl)
โโโ Decor system (torches, pillars, bookshelves, stained glass, portals, forge, anvil)
โโโ Holy Ledger terminal (interactive account/TX/chain browser after collecting all shards)
โโโ Breakable relic system (Integrity Sigil collectibles across 3 rooms)
โโโ Transaction animation system (floating receipts)
โโโ HUD (account info, volumes, LOG chain, shard count, API status)
โโโ Pause system (ESC to pause/resume, Web Audio suspend/resume)
โโโ Music mute toggle (M key, mutes theme only, SFX remain audible)
โโโ Game loop (60fps, requestAnimationFrame)
Canvas: 256ร240 (classic NES resolution), scaled 3ร to 768ร720
No dependencies. Pure HTML5 Canvas + vanilla JavaScript. Works offline.
Add an entry to the ROOMS object with a map (16ร12 grid), npcs, enemies, items, decor, and exits. Add a breakable relic entry in BREAKABLE_DECOR if the room should contain a Integrity Sigil.
Add an entry to a room's enemies array. Set type, hp, gold, and color. The ledger auto-creates an account for each enemy. Add rendering logic in the enemy draw function.
Add to a room's npcs array with id, name, lines (dialog), and optionally giveGold for gift transactions. Special NPC behaviors (like the Twins or Refund Imp) can be added with custom flags.
Add a playThemeName() method to the AUDIO object using startLoop(name, bpm, totalBeats, scheduleFn). Update loadRoom() to trigger the theme for the appropriate room.
Change ledger.bucket and API.ledgerName to use a different bucket/ledger name.
Each game session creates a unique ledger named ledgerquest-<timestamp> (e.g. ledgerquest-1773413892220) in the ledgerquest bucket. Find the name first, then query away:
# Find your game ledger (most recent first)
curl http://localhost:3068/v2/ | jq '.cursor.data[] | .name'
# โ "ledgerquest-1773413892220"
LEDGER="ledgerquest-1773413892220"
# List all game accounts
curl http://localhost:3068/v2/$LEDGER/accounts | jq
# Get hero's full account with volumes
curl "http://localhost:3068/v2/$LEDGER/accounts/hero:wallet?expand=volumes" | jq
# List all transactions
curl http://localhost:3068/v2/$LEDGER/transactions | jq
# Get a specific transaction with effective volumes
curl "http://localhost:3068/v2/$LEDGER/transactions/1?expand=effectiveVolumes" | jq
# Get aggregated balances
curl http://localhost:3068/v2/$LEDGER/aggregate/balances | jq
# Count total transactions
curl -I http://localhost:3068/v2/$LEDGER/transactions
# Look for the Count headerBuilt to showcase Formance Ledger โ a programmable financial ledger for money-moving applications.
Game concept and implementation generated with Claude.