Cranks — Scheduled Execution
Cranks allow you to schedule transactions that execute automatically at defined intervals on an Ephemeral Rollup. This is useful for game loops, periodic state updates, or any recurring on-chain operation.
Enable Cranks
CLI:
mb-console project configure my-game --cranks Web: Project Settings → Features → toggle “Cranks” on.
Create a Crank
CLI
mb-console crank create
--interval 5000
--iterations 100
--project my-game Parameters:
| Parameter | Type | Description |
|---|---|---|
--interval | ms | Time between executions |
--iterations | number | Total number of executions (0 = infinite) |
--project | string | Target project |
Web
Project → Cranks → “New Crank” → configure interval and iteration count → confirm.
MCP
Use the create_crank tool:
“Set up a crank that runs every 5 seconds for 100 iterations in my-game”
List Cranks
mb-console crank list --project my-game Output:
ID Interval Iterations Executed Status
crank_1 5000ms 100 42 running
crank_2 10000ms 0 (∞) 1,204 running
crank_3 1000ms 500 500 completed Stop a Crank
mb-console crank stop <CRANK_ID> How It Works
Cranks are implemented as scheduled tasks on the ER validator:
- You define a task with
task_id,execution_interval_millis, anditerations - The instruction is serialized and submitted to the Magic Program
- The ER validator executes the instruction at each interval
- Execution continues until the iteration count is reached or the crank is stopped
Use Cases
- Game loops: update game state every tick (e.g., every 100ms)
- Price updates: sync oracle data at regular intervals
- Cleanup jobs: expire stale sessions, process queued actions
- Reward distribution: periodic reward calculations
Cost
Crank executions on ER are gasless (zero transaction fee per execution). You only pay the standard session and commit fees.
Monitoring
mb-console monitor status --project my-game The Cranks tab shows:
- Active cranks and their status
- Execution count and success rate
- Next scheduled execution
Next Steps
- Oracle — real-time price feeds
- Gasless Transactions — zero-fee execution