Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
A minimal multisig contract where multiple signatures are required to execute a function.
#[program]
mod multisig {
use super::*;
#[account]
pub struct MultiSig {
pub approvals: u8,
pub threshold: u8,
}
pub fn approve(ctx: Context<Approve>) -> Result<()> {
let multisig = &mut ctx.accounts.multisig;
multisig.approvals += 1;
if multisig.approvals >= multisig.threshold {
// Execute transaction
}
Ok(())
}
#[derive(Accounts)]
pub struct Approve<'info> {
#[account(mut)]
pub multisig: ProgramAccount<'info, MultiSig>,
pub signer: Signer<'info>,
}
}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.