Quick Access
Check out basic counter example:Step-By-Step Guide
Build your program and upgrade it with delegation hooks with MagicBlock’s Delegation ProgramDELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh:
Add CPI hooks to delegate, commit and undelegate state accounts through
Ephemeral Rollup sessions.
These public validators are supported for development. Make sure to add the specific ER validator in your instruction when delegating:
- Asia (devnet-as.magicblock.app):
MAS1Dt9qreoRMQ14YQuhg8UTZMMzDdKhmkZMECCzk57 - EU (devnet-eu.magicblock.app):
MEUGGrYPxKk17hCr7wpT6s8dtNokZj5U2L57vjYMS8e - US (devnet-us.magicblock.app):
MUS3hc9TCw4cGC12vHNoYcCGzJG1txjgQLZWVoeNHNd - TEE (tee.magicblock.app):
FnE6VJT5QNZdedZPnCoLsARgBwoE6DeJNjBs2H1gySXA - Local ER (localhost):
mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev
Counter Example

| Software | Version | Installation Guide |
|---|---|---|
| Solana | 2.3.13 | Install Solana |
| Rust | 1.85.0 | Install Rust |
| Anchor | 0.32.1 | Install Anchor |
| Node | 24.10.0 | Install Node |
Code Snippets
- 1. Write program
- 2. Delegate
- 3. Deploy
- 4. Test
The program implements two main instructions:Nothing special here, just a simple Anchor program that increments a counter. The only difference is that we’re adding the
initialize: Sets the counter to 0increment: Increments the counter by 1
Delegate: Delegates counter from Base Layer to ER (called on Base Layer)CommitAndUndelegate: Schedules sync of counter from ER to Base Layer, and undelegates counter on ER (called on ER)Commit: Schedules sync of counter from ER to Base Layer (called on ER)Undelegate:- Schedules sync and undelegation of counter (called on ER)
- Undelegation triggered through callback instruction injected through #[ephemeral] (called on Base Layer through validator CPI)
ephemeral macro for undelegation and delegate macro to inject some useful logic to interact with the delegation program.⬆️ Back to TopAdvanced Code Snippets
- Resize PDA
- Magic Router
- Magic Action
- On-Curve Delegation
When resizing a delegated PDA:⬆️ Back to Top
- PDA must have enough lamports to remain rent-exempt for the new account size.
- If additional lamports are needed, the payer account must be delegated to provide the difference.
- PDA must be owned by the program, and the transaction must include any signer(s) required for transferring lamports.
- Use
system_instruction::allocate
Quick Access
Learn more about private ER, Rust Native implementation, and local development:Solana Explorer
Get insights about your transactions and accounts on Solana:Solana RPC Providers
Send transactions and requests through existing RPC providers:Solana Validator Dashboard
Find real-time updates on Solana’s validator infrastructure:Server Status
Subscribe to Solana’s and MagicBlock’s server status:Solana Status
Subscribe to Solana Server Updates
MagicBlock Status
Subscribe to MagicBlock Server Status
MagicBlock Products
Ephemeral Rollup (ER)
Execute real-time, zero-fee transactions securely on Solana.
Private Ephemeral Rollup (PER)
Protect sensitive data with privacy-preserving computation.
Verifiable Randomness Function (VRF)
Generate provably fair randomness directly on-chain.

