Docs/Examples/Crumblecore

CrumbleCore (Decay Tower)

A persistent on-chain tower where floors take autonomous VRF damage every tick.


Overview

CrumbleCore is the flagship AutoLoop demo game — a persistent tower where each floor decays continuously and takes catastrophic damage on autonomous VRF ticks.

PropertyValue
Base contractAutoLoopVRFCompatible
VRF usageEvery tick (full VRF)
Gas per tick~50k (+ ~240k VRF verification)
Sourceautoloop/src/games/CrumbleCore.sol
Tests67 passing (unit + invariant + fuzz)

Why AutoLoop Is Structurally Required

Inverted self-interest: every VRF tick picks a random active floor and applies 15-50% damage. No rational floor owner will ever call progressLoop() themselves — the VRF output could pick their own floor. This is the single sharpest answer to the critique that self-incentivized triggering can replace paid keepers.

The loop runs precisely because no rational player will run it. A neutral keeper (AutoLoop) is the only party whose incentives align with keeping the game alive.

Game Mechanics

  • Floors: minted with configurable insurance. Higher floor numbers cost more (linear scaling).
  • Passive decay: health decreases continuously based on wall-clock time since last repair.
  • Catastrophic damage: each VRF tick picks one random floor and applies 1500-5000 basis points of damage.
  • Collapse: when effective health reaches zero, the floor is permanently collapsed. Insured owners can claim a salvage payout from the shared insurance pool.
  • Repair: owners pay a fixed fee to fully restore health.
  • Insurance pool: shared across all insured floors. Target payout is 50% of mint fee, prorated if the pool is short. Anyone can donate to top up the pool.

Revenue Model

All fees accrue to protocolFeeBalance, withdrawable by the contract admin (Lucky Machines):

  • Mint fees (100% to protocol)
  • Repair fees (100% to protocol)
  • Insurance premiums (to shared insurance pool — 20%+ retained as operator edge)
  • AutoLoop gas fees on each tick (separate, collected by the AutoLoop core contract)

Deploy

forge script script/DeployGames.s.sol \
  --rpc-url $RPC_URL \
  --private-key $PRIVATE_KEY \
  --broadcast

Or deploy CrumbleCore individually:

forge create src/games/CrumbleCore.sol:CrumbleCore \
  --constructor-args 10000000000000000 2000000000000000 60 10000 100 1000 5000 \
  --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

Constructor args: baseMintFee, repairFee, tickInterval, maxHealth, passiveDecayPerHour, insurancePremiumBps, salvageTargetBps.

VRF Key Registration

After deploying, register the worker's VRF public key:

crumbleCore.registerControllerKey(controllerAddress, pkX, pkY);

The worker derives the public key from its private key via secp256k1. Without this step, VRF proof verification will reject every tick.

Dashboard

Play CrumbleCore on the AutoLoop Dashboard.