Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Uses seeds to deterministically create program accounts.
#[program]
mod seeds_example {
use super::*;
pub fn create_account(ctx: Context<Create>, seed: u64) -> Result<()> {
let account = &mut ctx.accounts.my_account;
account.data = seed;
Ok(())
}
#[derive(Accounts)]
pub struct Create<'info> {
#[account(init, seeds=[b"seed", &seed.to_le_bytes()], bump, payer=user, space=8+8)]
pub my_account: ProgramAccount<'info, MyAccount>,
#[account(signer)]
pub user: AccountInfo<'info>,
pub system_program: Program<'info, System>,
}
#[account]
pub struct MyAccount {
pub data: 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.