Software Packages
The following software packages may be required, other versions may also be compatible:Software | Version | Installation Guide |
---|---|---|
Solana | 2.1.21 | Install Solana |
Rust | 1.82.0 | Install Rust |
Quick Access
If you prefer to dive straight into the code:Write your program
- Overview
- Delegate
- Commit
- Undelegate
Core Functionality
The program implements two main instructions:InitializeCounter
: Initialize and sets the counter to 0 (called on Base Layer)IncreaseCounter
: Increments the initialized counter by X amount (called on Base Layer or ER)
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
: Undelegates counter on the Base Layer (called on Base Layer through validator CPI)
Your “Undelegate” instruction must have the exact discriminator. It is never
called by you, instead the validator on the Base Layer will callback with a
CPI into your program after undelegating your account on ER.