⚠️ Important: Upgrade your program with local 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 valdiators are supported for development. Make sure to upgrade your program with the specific ER validator in delegation config:
  • Asia (devnet): MAS1Dt9qreoRMQ14YQuhg8UTZMMzDdKhmkZMECCzk57
  • EU (devnet): MEUGGrYPxKk17hCr7wpT6s8dtNokZj5U2L57vjYMS8e
  • US (devnet): MUS3hc9TCw4cGC12vHNoYcCGzJG1txjgQLZWVoeNHNd
  • Local ER (localhost): 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
Explore delegation and test scripts for both Anchor and Native Rust: