Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Transfers SOL from one account to another using Anchor.
#[program]
mod sol_transfer {
use super::*;
pub fn transfer(ctx: Context<Transfer>, amount: u64) -> Result<()> {
**ctx.accounts.from.try_borrow_mut_lamports()? -= amount;
**ctx.accounts.to.try_borrow_mut_lamports()? += amount;
Ok(())
}
#[derive(Accounts)]
pub struct Transfer<'info> {
#[account(mut)]
pub from: Signer<'info>,
#[account(mut)]
pub to: AccountInfo<'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.