Navigate:
Anchor
~$ANCHO0.1%

Anchor: Solana Program Development Framework

A Rust-based framework for building Solana programs with IDL generation and TypeScript client support.

LIVE RANKINGS • 12:18 PM • STEADY
OVERALL
#299
113
CRYPTO
#10
10
30 DAY RANKING TREND
ovr#299
·Crypt#10
STARS
5.0K
FORKS
1.9K
7D STARS
+7
7D FORKS
+10
Tags:
See Repo:
Share:

Learn more about Anchor

Anchor is a development framework for building programs on the Solana blockchain. It provides a Rust embedded domain-specific language (eDSL) that abstracts low-level Solana program development complexities. The framework generates Interface Description Language (IDL) specifications from Rust code and includes tooling for TypeScript client generation. Anchor includes CLI tools for workspace management and is commonly used for developing decentralized applications on Solana.

Anchor

1

Rust eDSL

Provides high-level Rust abstractions for Solana program development with account validation and serialization handling.

2

IDL Generation

Automatically generates interface specifications from Rust code, enabling type-safe client generation across multiple languages.

3

Complete Toolchain

Includes CLI tools, workspace management, and both Rust and TypeScript client libraries for full-stack development.


use anchor_lang::prelude::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod my_program {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>, data: u64) -> Result<()> {
        let my_account = &mut ctx.accounts.my_account;
        my_account.data = data;
        my_account.authority = ctx.accounts.user.key();
        Ok(())
    }

    pub fn update(ctx: Context<Update>, new_data: u64) -> Result<()> {
        let my_account = &mut ctx.accounts.my_account;
        my_account.data = new_data;
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(
        init,
        payer = user,
        space = 8 + 8 + 32
    )]
    pub my_account: Account<'info, MyAccount>,
    #[account(mut)]
    pub user: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[derive(Accounts)]
pub struct Update<'info> {
    #[account(
        mut,
        has_one = authority
    )]
    pub my_account: Account<'info, MyAccount>,
    pub authority: Signer<'info>,
}

#[account]
pub struct MyAccount {
    pub data: u64,
    pub authority: Pubkey,
}


See how people are using Anchor

Loading tweets...


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers