Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Uses a program-derived address (PDA) to store data securely.
#[program]
mod pda_example {
use super::*;
pub fn store_data(ctx: Context<StoreData>, value: u64) -> Result<()> {
let my_account = &mut ctx.accounts.my_account;
my_account.value = value;
Ok(())
}
#[derive(Accounts)]
pub struct StoreData<'info> {
#[account(mut, seeds=[b"my_seed".as_ref()], bump)]
pub my_account: ProgramAccount<'info, MyAccount>,
}
#[account]
pub struct MyAccount {
pub value: u64,
}
}Anchor is a Rust-based framework for Solana smart contract (program) development, testing, and deployment. It simplifies building Solana dApps by providing a high-level abstraction over Solana programs and client interactions.
Origin & Creator
Anchor was created by Project Serum team members in 2020 to simplify Solana program development, reduce boilerplate, and improve developer productivity.
Industrial Note
Anchor is widely used in DeFi, NFT, and other Solana ecosystem projects, as it standardizes Solana program structure and automates common patterns like account validation and serialization.