What This Gets You
| Capability | How |
|---|---|
| Serverless multiplayer | CRDTs sync state across peers without a central server |
| Perfect replay | Every action recorded with actor and timestamp |
| Forkable worlds | Snapshot state, explore alternatives, compare outcomes |
| Offline-first | Peers diverge safely, converge mathematically |
| Persistence | Save and resume games with IndexedDB or filesystem adapters |
| Browser-ready | One command bundles any game for the browser |
How It Compares
| Traditional Engine | Blockchain Game | Raw CRDT (Automerge/Yjs) | HyperToken | |
|---|---|---|---|---|
| Multiplayer | Server authoritative | On-chain consensus | Manual networking | P2P CRDT sync, built-in |
| Cost | Monthly hosting | Gas fees per action | Relay only | Minimal β just a relay |
| Conflicts | Last-write-wins | Consensus delay | Mathematical merge | Mathematical merge |
| Offline | Disconnected | Cannot act | Diverge and merge | Diverge and merge safely |
| History | Server logs | On-chain events | Change log | Perfect replay + provenance |
| Forkable | Manual snapshots | Impossible | Manual clone/merge | Fork, diverge, merge back |
| Abstractions | Game objects | Smart contracts | None β raw documents | Tokens, agents, stacks, spaces |
Try It
git clone https://git.carpocratian.org/sibyl/hypertoken
cd hypertoken
npm install && npm run build
# Play Watershed in the browser
npm run relay # Terminal 1: start relay
npm run watershed:web # Terminal 2: build + serve
# Open http://localhost:8080 in two tabs
# Play Blackjack
npm run blackjack
# Play Cuttle
npm run cuttle
How It Works
Tokens Compose With Provenance
const enchantedSword = engine.dispatch("token:merge", {
tokens: [sword, fireEnchantment],
resultProperties: { label: "Flaming Sword" }
});
// enchantedSword._mergedFrom = [sword.id, fireEnchantment.id]
const pieces = engine.dispatch("token:split", {
token: goldPile,
count: 3
});
// pieces[0]._splitFrom = goldPile.id
State Syncs Automatically
const host = new Engine();
host.connect("ws://relay.local:8080");
const client = new Engine();
client.connect("ws://relay.local:8080");
// Both make changes β CRDTs merge β identical final state
// No conflict resolution code. It just works.
Persistence
const engine = new Engine();
// Use storage adapter (IndexedDB in browser,
// FilesystemAdapter in Node.js)
engine.useStorage(new IndexedDBAdapter());
// Save state
await engine.persist("my-game-session");
// Resume later β even after closing the browser
await engine.resume("my-game-session");
Forkable Worlds
// Fork the engine β divergent branch with new actor ID
const fork = engine.fork();
// Explore timeline A
fork.dispatch('token:merge', { tokens: [sword, fireEnchantment] });
const outcomeA = fork.getState();
// Merge changes back β CRDT conflict resolution
engine.mergeFrom(fork);
const outcomeB = engine.getState();
What's Inside
- 77 built-in actions β draw, shuffle, place, move, flip, merge, split, and more across 7 categories
- Rust/WASM core β ~20x performance over pure JS, with TypeScript fallback
- P2P networking β serverless CRDT sync (ConsensusCore) and host-authoritative mode
- Persistence β IndexedDB (browser) and Filesystem (Node.js) adapters with auto-save
- Browser builds β one command bundles any app for the browser
- MCP server β LLM integration via Model Context Protocol
- 3 example games β Blackjack (fully CRDT-backed card game), Cuttle (snapshot CRDT sync with encrypted hands), Watershed (field-level CRDT real-time showcase)
- Document compaction β discard CRDT history at phase boundaries to bound document size
- Forkable worlds β fork engine state, explore divergent timelines, merge back via CRDT conflict resolution
- Token provenance β every entity tracks its full merge/split history, useful for games, marketplaces, and collaborative tools