magicblock

Original🇺🇸 English
Translated

MagicBlock Ephemeral Rollups development patterns for Solana. Covers delegation/undelegation flows, dual-connection architecture (base layer + ER), cranks for scheduled tasks, VRF for verifiable randomness, and TypeScript/Anchor integration. Use for high-performance gaming, real-time apps, and fast transaction throughput on Solana.

16installs
Added on

NPX Install

npx skill4agent add magicblock-labs/magicblock-dev-skill magicblock

MagicBlock Ephemeral Rollups Skill

What this Skill is for

Use this Skill when the user asks for:
  • MagicBlock Ephemeral Rollups integration
  • Delegating/undelegating Solana accounts to ephemeral rollups
  • High-performance, low-latency transaction flows
  • Crank scheduling (recurring automated transactions)
  • VRF (Verifiable Random Function) for provable randomness
  • Dual-connection architecture (base layer + ephemeral rollup)
  • Gaming and real-time app development on Solana

Key Concepts

Ephemeral Rollups enable high-performance, low-latency transactions by temporarily delegating Solana account ownership to an ephemeral rollup. Ideal for gaming, real-time apps, and fast transaction throughput.
Delegation transfers account ownership from your program to the delegation program, allowing the ephemeral rollup to process transactions at ~10-50ms latency vs ~400ms on base layer.
Architecture:
┌─────────────────┐     delegate      ┌─────────────────────┐
│   Base Layer    │ ───────────────►  │  Ephemeral Rollup   │
│    (Solana)     │                   │    (MagicBlock)     │
│                 │  ◄───────────────  │                     │
└─────────────────┘    undelegate     └─────────────────────┘
     ~400ms                                  ~10-50ms

Default stack decisions (opinionated)

  1. Programs: Anchor with ephemeral-rollups-sdk
    • Use
      ephemeral-rollups-sdk
      with Anchor features
    • Apply
      #[ephemeral]
      macro before
      #[program]
    • Use
      #[delegate]
      and
      #[commit]
      macros for delegation contexts
  2. Dual Connections
    • Base layer connection for initialization and delegation
    • Ephemeral rollup connection for operations on delegated accounts
  3. Transaction Routing
    • Delegate transactions → Base Layer
    • Operations on delegated accounts → Ephemeral Rollup
    • Undelegate/commit transactions → Ephemeral Rollup

Operating procedure (how to execute tasks)

1. Classify the operation type

  • Account initialization (base layer)
  • Delegation (base layer)
  • Operations on delegated accounts (ephemeral rollup)
  • Commit state (ephemeral rollup)
  • Undelegation (ephemeral rollup)

2. Pick the right connection

  • Base layer:
    https://api.devnet.solana.com
    (or mainnet)
  • Ephemeral rollup:
    https://devnet.magicblock.app/

3. Implement with MagicBlock-specific correctness

Always be explicit about:
  • Which connection to use for each transaction
  • Delegation status checks before operations
  • PDA seeds matching between delegate call and account definition
  • Using
    skipPreflight: true
    for ER transactions
  • Waiting for state propagation after delegate/undelegate

4. Add appropriate features

  • Cranks for recurring automated transactions
  • VRF for verifiable randomness in games/lotteries

5. Deliverables expectations

When you implement changes, provide:
  • Exact files changed + diffs
  • Commands to install/build/test
  • Risk notes for anything touching delegation/signing/state commits

Progressive disclosure (read when needed)

  • Core delegation patterns: delegation.md
  • TypeScript frontend setup: typescript-setup.md
  • Cranks (scheduled tasks): cranks.md
  • VRF (randomness): vrf.md
  • Reference links & versions: resources.md