Skip to main content

Quickstart

Get started with Ephemeral Rollups by running the Anchor Counter example. This guide will have you delegating accounts, executing low-latency transactions, and committing state back to Solana in under 10 minutes.

Prerequisites

Before you begin, ensure you have the following tools installed:
Use version managers like agave-install for Solana, rustup for Rust, and avm for Anchor to easily switch between versions.

Verify your installations

Run the Anchor Counter example

1

Clone the repository

Clone the MagicBlock Engine examples repository:
2

Install dependencies

Install the required Node.js packages:
The project uses:
  • @coral-xyz/anchor (0.32.1) - Anchor framework
  • @magicblock-labs/ephemeral-rollups-sdk (0.6.5) - Ephemeral Rollups SDK
3

Build and deploy

Build the program and deploy it to the configured cluster:
If you want to deploy with a fresh program ID, delete the keypair first:
4

Run the tests

Execute the test suite to see delegation, execution, and commits in action:
You’ll see output showing:
  • Counter initialization on Solana base layer
  • Account delegation to Ephemeral Rollup
  • Fast increment transactions on the ER
  • State commits back to Solana
  • Account undelegation

Understanding the code

The Counter program

The Anchor Counter program demonstrates the core Ephemeral Rollup pattern:
anchor-counter/programs/anchor-counter/src/lib.rs
The #[ephemeral] attribute on the program enables Ephemeral Rollup support. The #[delegate] attribute on the context generates delegation boilerplate.

Delegating an account

Delegation transfers account ownership to the delegation program, making it available in the Ephemeral Rollup:
anchor-counter/tests/anchor-counter.ts

Executing on Ephemeral Rollup

Once delegated, transactions execute with millisecond latency:

Committing state

Commit account state back to Solana:

Test output explained

When you run the tests, you’ll see timing comparisons:
Ephemeral Rollup transactions execute 40-50x faster than base layer transactions.

Next steps

Core Concepts

Learn how delegation, commits, and transaction routing work

Framework Examples

Explore examples for different Solana frameworks

Local Development

Set up a local Ephemeral Rollup validator

Advanced Examples

Try cranks, Magic Actions, and session keys

Troubleshooting

Wait a few seconds after delegation before executing transactions on the ER. Account propagation takes 2-3 seconds:
Make sure you’ve deployed to the correct cluster. Check your Anchor.toml:
Then deploy:
Ensure all tools match the required versions:
Use version managers to switch versions as needed.
Make sure your wallet has SOL on the target cluster:
The Ephemeral Rollups are currently in testing. Contact the MagicBlock team on Discord to get access to the testing endpoint.