Skip to main content

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.


Quick Access

Magic Actions Example

Explore reference implementation on GitHub

Setup Router Connection

Use Magic Router to route and send transactions to ER and base layer.
import { Connection } from "@magicblock-labs/ephemeral-rollups-kit";

// Initialize connection
const connection = await Connection.create(
  "https://devnet-router.magicblock.app",
  "wss://devnet-router.magicblock.app"
);

// ... create transaction

// Send and confirm transaction
const txHash = await connection.sendAndConfirmTransaction(
  transactionMessage,
  [userKeypair],
  { commitment: "confirmed", skipPreflight: true }
);

Transaction Flow

  1. Delegate counter to ER
const delegateTx = await program.methods
  .delegate()
  .accounts({
    payer: anchor.Wallet.local().publicKey,
    pda: pda,
  })
  .transaction();
  1. Increment counter on ER in real-time
const incrementTx = await program.methods
  .increment()
  .accounts({
    counter: pda,
  })
  .transaction();
  1. Commit with Magic Action
const commitTx = await program.methods
  .commitAndUpdateLeaderboard()
  .accounts({ payer: wallet.publicKey /* your accounts */ })
  .transaction();

Examples

Quickstart Ephemeral Rollups

End-to-end walkthrough on ER usage

Magic Router

Router overview and flow