Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Quickstart

Requirements: Node ≥ 20 with corepack and mdBook 0.5.2 for building the bundled documentation (see toolchains). Rust (with the wasm32-unknown-unknown target) and Python 3 are only needed if you want to rebuild WASM artifacts or compile DSL contracts — prebuilt artifacts are committed.

git clone <repo> && cd zechariah
pnpm install
pnpm build        # typecheck + emit all packages and bundle documentation
pnpm test         # the full suite: 150+ tests incl. multi-validator devnets

Try the browser demos

After building, run node scripts/node-demo.mjs and open http://127.0.0.1:8790. Create or load a wallet in Wallet, download its backup, and claim test CAI in Faucet. The Demos menu includes Hex, Frontier, Outpost, Chess, Microblog, and Bounties. The same wallet works across every tab.

The launcher preserves its chains, worlds, posts and deployment journal under .mordecai-demo/. Restarting keeps that state; do not delete it to update the UI. Wallet keys stay in the browser tab and must be loaded again after a page reload. Use another wallet or browser tab to play an opponent, tip an author, or answer a bounty.

1. Run a local devnet

node apps/devnet/devnet.mjs 4

This spins up an in-process DHT testnet and four consensus validators, and prints:

node-0  rpc key: f414d2a9d2a1…      ← dial any of these over the DHT
faucet address:   rb6rdrgkf19z…
faucet mnemonic:  video cheese twice …   ← a funded wallet for playing
dht bootstrap:    127.0.0.1:49737

Leave it running. Everything below talks to it via the printed bootstrap address and RPC keys.

2. Create a wallet and move money

export MORDECAI_WALLET_PASSPHRASE=dev
node packages/wallet/dist/cli.js create --keystore alice.json
node packages/wallet/dist/cli.js address --keystore alice.json

Sign a transfer (the CLI prints the canonical signed transaction as hex):

node packages/wallet/dist/cli.js transfer \
  --keystore alice.json --to <address> --amount 1000 \
  --nonce 0 --chain-id mordecai-devnet

Programmatic submission goes through the SDK (next step) or the RPC client; see CLI Tools for the full command reference.

3. Talk to the chain from code

import { Mordecai } from '@mordecai/sdk';
import { Wallet } from '@mordecai/wallet';

const { wallet, mnemonic } = Wallet.create(); // or Wallet.fromMnemonic(faucet)
const app = Mordecai.connect({
  wallet,
  nodeKey: Buffer.from('<rpc key hex>', 'hex'),
  storageDir: './app-data',
  chainId: 'mordecai-devnet',
  bootstrap: [{ host: '127.0.0.1', port: 49737 }],
});

const receipt = await app.transfer('<address>', 250_000n);
console.log(receipt.success, receipt.height); // finalized, with block height

4. Deploy a contract written in Python-like DSL

./compiler/mordecaic check compiler/examples/chess_wager.pysc
./compiler/mordecaic build compiler/examples/chess_wager.pysc -o build/wager --wasm
const { contractId } = await app.deploy(wasmBytes);
await app.execute(contractId, 'create', new Uint8Array(0), 100_000n); // 100k stake attached

5. Run the flagship example

The chess app plays a full wagered match — escrow on-chain, every move peer-to-peer — in under two seconds:

pnpm vitest run apps/chess

From here: read What a P2P App Is (and Isn’t) before designing your app — the on-chain/off-chain split is the one decision that shapes everything else.