Learn how to write a simple Anchor program that increments a counter on Solana
Software | Version | Installation Guide |
---|---|---|
Solana | 2.1.21 | Install Solana |
Rust | 1.82.0 | Install Rust |
Anchor | 0.31.1 | Install Anchor |
initialize
: Sets the counter to 0increment
: Increments the counter by 1delegate
macro to inject some useful logic to interact with the delegation program.
delegate_account
function. delegate_account
will CPI to the delegation program, which upon validation will gain ownership of the account.
After this step, an ephemeral validator can start processing transactions on the counter PDA and propose state diff trough the delegation program.
commit_accounts
function.
commit_and_undelegate_accounts
as part of some instruction.
Undelegation commit the latest state and give back the ownership of the PDA to the owner program.