Skip to main content

Lifecycle of the Integration

The lifecycle of integrating Ephemeral Rollups in your program is as follows:
1

Write your program

Write your Solana program as you normally would.
2

Add delegation and undelegation hooks in your program

Add CPI hooks to delegate, commit and undelegate state accounts through Ephemeral Rollup sessions.
3

Deploy your program on Solana.

Deploy your program directly on Solana using Anchor or Solana CLI.
4

Ready to execute transactions for delegation and real-time speed

Send transactions without modifications on-chain and off-chain that also comply with the SVM RPC specification.

Counter Example

The following software packages may be required, other versions may also be compatible:
SoftwareVersionInstallation Guide
Solana2.1.21Install Solana
Rust1.82.0Install Rust
Anchor0.31.1Install Anchor
Find the full basic counter example for Rust Native and Anchor framework implementation:
  • 1. Write program
  • 2. Delegate
  • 3. Deploy
  • 4. Test
A simple counter program where value is initialized and incremented in a state account:
#[program]
pub mod anchor_counter {
    use super::*;

    /// Initialize the counter.
    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
        let counter = &mut ctx.accounts.counter;
        counter.count = 0;
        Ok(())
    }

    /// Increment the counter.
    pub fn increment(ctx: Context<Increment>) -> Result<()> {
        let counter = &mut ctx.accounts.counter;
        counter.count += 1;
        Ok(())
    }

    // ... Additional instructions will be added here
}

/// Context for initializing counter
#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(init_if_needed, payer = user, space = 8 + 8, seeds = [TEST_PDA_SEED], bump)]
    pub counter: Account<'info, Counter>,
    #[account(mut)]
    pub user: Signer<'info>,
    pub system_program: Program<'info, System>,
}


/// Context for incrementing counter
#[derive(Accounts)]
pub struct Increment<'info> {
    #[account(mut, seeds = [TEST_PDA_SEED], bump)]
    pub counter: Account<'info, Counter>,
}

/// Counter struct
#[account]
pub struct Counter {
    pub count: u64,
}
⬆️ Back to Top

I