🗺

The Plan

Static Frontend + TN12 Node. No Backend.

The BlockDAG is the server.

The Goal

Run The DAG Gate as a static frontend that connects directly to a Kaspa TN12 node via wRPC WebSocket. Game state lives on-chain as covenant-enforced UTXOs. No backend server. No database. No middleware. The browser talks to the BlockDAG.

Architecture

GitHub Pages (static)          TN12 Node
┌──────────────┐         ┌──────────────────┐
│  HTML/CSS/JS │         │  wRPC JSON :18310 │
│  kaspa-wasm  │◄──WSS──►│  Covenant engine  │
│  (tx build)  │         │  ZK verification  │
└──────────────┘         └──────────────────┘

Browser reads UTXOs, builds covenant txs via kaspa-wasm, signs locally, submits via wRPC.

Phase 0 (Done)

Playable Demo

  • ✓ BBS terminal aesthetic with CRT scanlines
  • ✓ Full game loop: create character, forest combat, shop, inn, PvP
  • ✓ Architecture explainer mapping game mechanics to covenants
  • ✓ localStorage persistence

Phase 1: Live TN12 Connection (Done)

Browser connects directly to our TN12 node via wRPC WebSocket. All covenant operations — UTXO lookups, transaction submission, block info — go through wRPC.

Own TN12 Node

Running kaspad from the tn12 branch on a DigitalOcean droplet. wRPC endpoint at wss://tn12.dagknight.xyz. Fully synced, accepting covenant transactions that public APIs reject as "non-standard".

Browser Tx Construction

@kasdk/web WASM SDK runs in browser. PrivateKey, ScriptBuilder, Transaction, createInputSignature (Schnorr) all proven. Custom covenant scripts built and submitted via wRPC.

No Backend Server

Static site on GitHub Pages. Browser connects to TN12 node via WebSocket. Only infrastructure: the node itself and a CPU miner that funds new players from block rewards. The BlockDAG is the server.

Phase 2: On-Chain Game State (Done)

Character state lives on-chain as a covenant-enforced UTXO. The browser builds, signs, and submits real covenant transactions through our TN12 node. Game rules are enforced by the L1.

Proven On-Chain

✅ SilverScript player.sil compiled to 160-byte bytecode — single entrypoint, checkSig + validateOutputState
✅ Fund Players On-node faucet sends 1 KAS from mining rewards — funds wallet + deploys 3 covenants in one tx
✅ Create Covenant Player covenant UTXO deployed on TN12 via P2SH — wRPC submission bypasses standardness check
✅ State Transition Covenant spent + recreated with new state (hp, gold, level) — validateOutputState verified on-chain
✅ Owner Signature Schnorr checkSig verifies only the owner can update their character — proven on TN12
✅ Game Integration Every game action (combat, shop, inn, PvP, death) triggers on-chain covenant state update
✅ ICC: Player+Shop Atomic transaction: Player covenant (gold decreased) + Shop covenant (gold collected) — two P2SH inputs, two outputs, one tx
✅ ICC: Player+Opponent Atomic PvP: Player + NPC Opponent covenants updated in one tx — winner gains gold, loser loses gold
✅ UTXO Outpoint Caching Cached tx outpoints eliminate UTXO lookup race conditions for rapid state updates at 10 BPS

SilverScript Covenants

player.sil (LIVE)

Self-preserving UTXO. 160 bytes compiled from SilverScript. Holds owner pubkey, HP, gold, level. Every spend recreates the UTXO with updated state. Owner-signed via Schnorr checkSig. State validated via validateOutputState. Game rules enforced on L1: require(newLevel >= level).

Verifiable Combat (LIVE)

Deterministic from BlockDAG. Combat seed derived from the node's tip block hash. Monster selection and all damage rolls use a seeded xorshift64 PRNG — deterministic and replayable. Anyone can verify combat outcomes given the seed + player stats. No separate covenant needed.

shop.sil (LIVE)

Persistent shared state. 56 bytes compiled from SilverScript. Tracks gold collected. ICC with Player covenant: atomic tx validates gold transfer in a single transaction. Two covenants, one tx, zero trust.

opponent.sil (LIVE)

PvP NPC covenant. 80 bytes compiled from SilverScript. Tracks opponent HP and gold. ICC with Player covenant: atomic PvP resolution in a single transaction. Winner gains gold, loser loses gold. Three covenants deployed per player: 296 bytes total on-chain.

ZK Proof Generation

Complex combat math runs off-chain in a RISC Zero guest program. Input: player stats, monster stats, random seed from block hash. Output: valid state transition (new HP, XP, gold). The proof is submitted alongside the covenant spend — the L1 verifies without re-executing. For simpler math, inline SilverScript validation avoids proof overhead entirely.

Phase 3: Multiplayer

Player Registry (LIVE)

Active Knights panel shows all players with name, class, and level. On-node indexer tracks registrations. Players register on character creation. Real-time leaderboard without scanning UTXOs.

Protocol-Native Mechanics

Daily fight reset: require(this.age > 86400) on Player UTXO — no server clock needed. Gold = locked test KAS (sompi). PvP stakes: both players lock KAS, winner takes pot.

Resolved Questions

Open Questions

The Covenant Forge — how the magic works →
← Back to The DAG Gate