> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magicblock.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Automated, time-based execution of on-chain instructions

## What Are Cranks?

Cranks (scheduled tasks) enable **automated, time-based execution** of on-chain instructions without requiring manual user intervention. In traditional blockchain systems, every action requires a user to sign and submit a transaction, which limits automation capabilities.

With MagicBlock's Ephemeral Rollups, you can schedule tasks that execute automatically at predetermined intervals, bringing powerful automation capabilities to your Solana programs.

## Key Benefits

* **Automated Execution**: Programs can execute instructions at predetermined intervals without user interaction
* **Cost Efficiency**: Reduces the need for off-chain cron jobs or monitoring services
* **Decentralization**: Execution happens on-chain, maintaining trustless guarantees
* **Reliability**: Scheduled tasks execute reliably within the blockchain's consensus mechanism

## Use Cases

* **Periodic State Updates**: Update prices, clear expired data, or refresh game state
* **Automated Workflows**: Recurring payments, vesting schedules, or subscription renewals
* **Game Mechanics**: Periodic rewards, time-based events, or automated game progression
* **DeFi Operations**: Rebalancing portfolios, liquidation checks, or yield compounding

> [card] [Implementation](https://docs.magicblock.gg/pages/tools/crank/implementation.md)
>
> Learn how to implement cranks in your program

> [card] [Code Example](https://github.com/magicblock-labs/magicblock-engine-examples/tree/main/crank-counter/anchor)
>
> Check out our GitHub repository

> [card] [Automate prediction-market settlement](https://docs.magicblock.gg/pages/solutions/prediction-markets.md)
>
> See where cranks fit into expiry checks, liquidation checks, and settlement.

## How It Works

Cranks leverage MagicBlock's Ephemeral Rollups to provide scheduled execution:

1. **Initialize** your program state on Solana base layer
2. **Delegate** accounts to Ephemeral Rollup for faster execution
3. **Schedule** a crank task that automatically executes instructions
4. **Execute** automatically at specified intervals
5. **Undelegate** accounts back to Solana base layer when done

The scheduling happens through Cross-Program Invocation (CPI) to MagicBlock's scheduling program, which handles the actual execution timing and reliability.

Cranks execute within the Ephemeral Rollup's consensus mechanism, ensuring reliable and trustless execution. For detailed implementation steps, see the [Implementation](https://docs.magicblock.gg/pages/tools/crank/implementation.md) guide.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.