Skip to main content
Account delegation is the process of temporarily transferring ownership of an account to the MagicBlock delegation program. Once delegated, the account can be used in an Ephemeral Rollup where transactions execute with minimal latency.

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
The #[component(delegate)] attribute automatically makes the component delegatable.

Client-side delegation

Delegation configuration

The DelegateConfig struct allows you to customize delegation behavior:

Commit frequency

The commit_frequency_ms parameter controls how often the ER automatically commits state back to Solana:
Setting a very low commit frequency increases base layer transaction costs. Balance latency needs with cost considerations.

Validator selection

You can optionally specify which ER validator should handle the delegation:
For local development, you typically need to specify the local validator identity:

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:
Undelegation automatically commits the latest state to the base layer before returning ownership.

Examples using delegation

Next steps

Transaction execution

Learn how to execute transactions in Ephemeral Rollups

Ephemeral Rollups

Understand the full ER architecture