Skip to main content

Why Use a Local Setup?

When testing delegations and real-time behavior of your Solana programs, fast feedback loops are critical. Running a Local Ephemeral Rollup Validator allows you to:
  • Test delegations and behaviors quickly without network latency or rate limits.
  • Simulate Solana runtime transactions locally.
  • Customize your validator setup for your own needs.

Quickstart: Local Ephemeral Validator

Explore delegation and test scripts for both Anchor and Native Rust:

⚠️ Important: Upgrade your program with the correct validator identity

When using a local ER validator, you need to connect it to your preferred base layer (e.g., mainnet-beta, devnet, or localhost) where the accounts are delegated. To delegate your PDA to a specific ER validator identity, you must update the delegation config in your program. This ensures that accounts can be properly committed and undelegated on the base layer.

These public validators are supported for development. Make sure to add the specific ER validator in your delegation instruction:

Mainnet
  • Asia (as.magicblock.app): MAS1Dt9qreoRMQ14YQuhg8UTZMMzDdKhmkZMECCzk57
  • EU (eu.magicblock.app): MEUGGrYPxKk17hCr7wpT6s8dtNokZj5U2L57vjYMS8e
  • US (us.magicblock.app): MUS3hc9TCw4cGC12vHNoYcCGzJG1txjgQLZWVoeNHNd
Devnet
  • Asia (devnet-as.magicblock.app): MAS1Dt9qreoRMQ14YQuhg8UTZMMzDdKhmkZMECCzk57
  • EU (devnet-eu.magicblock.app): MEUGGrYPxKk17hCr7wpT6s8dtNokZj5U2L57vjYMS8e
  • US (devnet-us.magicblock.app): MUS3hc9TCw4cGC12vHNoYcCGzJG1txjgQLZWVoeNHNd
  • TEE (tee.magicblock.app): FnE6VJT5QNZdedZPnCoLsARgBwoE6DeJNjBs2H1gySXA
Localnet
  • Local ER (localhost:7799): mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev

Deploy and test on base layer via correct validator identity

1

Set up Solana Test Validator (Localhost) and deploy your upgraded program

  1. Install solana-test-validator:
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
  1. Run solana-test-validator with cloned delegation program and accounts from Devnet:
solana-test-validator \
  --ledger ./my-ledger-1 \
  --reset \
  --clone mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev \
  --clone EpJnX7ueXk7fKojBymqmVuCuwyhDQsYcLVL1XMsBbvDX \
  --clone 7JrkjmZPprHwtuvtuGTXp9hwfGYFAQLnLeFM52kqAgXg \
  --clone noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV \
  --clone-upgradeable-program DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh \
  --url https://api.devnet.solana.com
  1. Upgrade and deploy your program to localhost:
cargo build-sbf
solana config set --url localhost
solana program deploy YOUR_PROGRAM_PATH
2

Install and run MagicBlock ER validator (Localhost)

  1. Install the latest MagicBlock Ephemeral Validator:
npm install -g @magicblock-labs/ephemeral-validator@latest
  1. Run the local ephemeral validator pointing to localhost:
RUST_LOG=info ephemeral-validator \
  --accounts-lifecycle ephemeral \
  --remote-cluster development \
  --remote-url http://127.0.0.1:8899 \
  --remote-ws-url ws://127.0.0.1:8900 \
  --rpc-port 7799
3

Test program instructions and delegation (Localhost)

Run your tests against the local ephemeral validator:
EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
PROVIDER_ENDPOINT=http://localhost:8899 \
WS_ENDPOINT=http://localhost:8900 \
yarn test