Magicblock

From x402agent/solana-clawd · View interactive version

Magicblock is an AI agent skill from the GitHub repository x402agent/solana-clawd. 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, magic actions for atomic ER-commit + base-layer follow-ups, private payments API (deposits, t

How to use this skill

Skill file

MagicBlock Ephemeral Rollups Skill

What this Skill is for

Use this Skill when the user asks for:

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.

MagicIntentBundleBuilder (SDK 0.11+) is the current way to schedule commit and commit-and-undelegate intents. The free functions commit_accounts and commit_and_undelegate_accounts are deprecated.

Private Ephemeral Rollups (PER) add a permission account that gates who can interact with a delegated account inside a TEE-backed validator. The recommended pattern is to delegate the permission account itself alongside the permissioned account, so member updates execute on the ER in milliseconds instead of base-layer round-trips.

Magic Actions are base-layer instructions scheduled inside an ER transaction via MagicIntentBundleBuilder.add_post_commit_actions(...). They execute atomically once the commit is sealed back to base layer — useful for leaderboard updates, reward distribution, and any side-effect that must run as part of the commit.

Commit sponsorship: every delegated account gets 10 free commits to base layer by default. To lift the cap, either re-delegate (refreshes the quota) or attach a magic_fee_vault PDA + delegated fee payer to the intent bundle.

Lamports top-up: when a delegated account (e.g. a delegated fee payer) needs more lamports on the ER side, use lamportsDelegatedTransferIx from the SDK. The transaction is submitted on base layer — the Ephemeral SPL Token program creates a single-use lamports PDA, funds it, and delegates it so the ER credits the destination.

Architecture:

┌─────────────────┐     delegate      ┌─────────────────────┐
│   Base Layer    │ ───────────────►  │  Ephemeral Rollup   │
│    (Solana)     │                   │    (MagicBlock)     │
│                 │  ◄───────────────  │                     │
└─────────────────┘    undelegate     └─────────────────────┘
     ~400ms                                  ~10-50ms

Default stack decisions (opinionated)

1) Programs: Anchor with ephemeral-rollups-sdk

2) Dual Connections

3) Transaction Routing

Operating procedure (how to execute tasks)

1. Classify the operation type

2. Pick the right connection

3. Implement with MagicBlock-specific correctness

Always be explicit about:

4. Diagnose possible service-side failures

For unexpected RPC, routing, oracle, or transaction errors that could be service-side:

5. Add appropriate features

6. Deliverables expectations

When you implement changes, provide:

Progressive disclosure (read when needed)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.