Overview
Delegation enables accounts to be processed by Ephemeral Rollup validators while maintaining state consistency with the Solana base layer. During delegation:- The account’s owner is temporarily changed to the delegation program
- The account can be modified through the ER with low latency
- State automatically commits back to Solana at configured intervals
- The account can be undelegated to return full control to the original owner
Delegation with Anchor
The Anchor framework provides the simplest way to add delegation support to your programs.Setup
The
#[delegate] macro automatically adds the required accounts for delegation (buffer, record, metadata, delegation program, etc.).Complete Anchor example
From the anchor-counter example:/home/daytona/workspace/source/anchor-counter/programs/anchor-counter/src/lib.rs
Delegation with native Rust
For programs that don’t use Anchor, you can delegate accounts using the native Rust SDK.Manual delegation
From the rust-counter example:/home/daytona/workspace/source/rust-counter/src/processor.rs
Delegation with Bolt
The Bolt framework provides ECS-style delegation using component attributes.Component delegation
From the bolt-counter example:/home/daytona/workspace/source/bolt-counter/programs-ecs/components/counter/src/lib.rs
#[component(delegate)] attribute automatically makes the component delegatable.
Client-side delegation
Delegation configuration
TheDelegateConfig struct allows you to customize delegation behavior:
Commit frequency
Thecommit_frequency_ms parameter controls how often the ER automatically commits state back to Solana:
Validator selection
You can optionally specify which ER validator should handle the delegation:PDA delegation
Delegation works seamlessly with Program Derived Addresses (PDAs). You must provide the seeds used to derive the PDA:The SDK uses these seeds to verify PDA ownership and recreate the account after undelegation.
Undelegating accounts
To return an account to the base layer and restore original ownership:- Anchor/TypeScript
- Native Rust
- Anchor Program
Examples using delegation
- Anchor Counter - Anchor-based delegation with automatic macros
- Rust Counter - Native Rust delegation implementation
- Bolt Counter - Component-based delegation with Bolt
- Pinocchio Counter - Lightweight delegation without Borsh
Next steps
Transaction execution
Learn how to execute transactions in Ephemeral Rollups
Ephemeral Rollups
Understand the full ER architecture