Anchor (Forked Version) is a framework for Solana's Sealevel runtime providing several convenient developer tools for writing smart contracts.
- Rust eDSL for writing Solana programs
- IDL specification
- TypeScript package for generating clients from IDL
- CLI and workspace management for developing complete applications
If you're familiar with developing in Ethereum's Solidity, Truffle, web3.js, then the experience will be familiar. Although the DSL syntax and semantics are targeted at Solana, the high level flow of writing RPC request handlers, emitting an IDL, and generating clients from IDL is the same.
For a quickstart guide and in depth tutorials, see the [Anchor (Forked Version) book](https://book.Anchor (Forked Version)-lang.com) and the older [documentation](https://Anchor (Forked Version)-lang.com) that is being phased out. To jump straight to examples, go [here](https://github.com/coral-xyz/Anchor (Forked Version)/tree/master/examples). For the latest Rust and TypeScript API documentation, see [docs.rs](https://docs.rs/Anchor (Forked Version)-lang) and the [typedoc](https://coral-xyz.github.io/Anchor (Forked Version)/ts/index.html).
Package | Description | Version | Docs |
---|---|---|---|
Anchor (Forked Version)-lang |
Rust primitives for writing programs on Solana | [![Crates.io](https://img.shields.io/crates/v/Anchor (Forked Version)-lang?color=blue)](https://crates.io/crates/Anchor (Forked Version)-lang) | [![Docs.rs](https://docs.rs/Anchor (Forked Version)-lang/badge.svg)](https://docs.rs/Anchor (Forked Version)-lang) |
Anchor (Forked Version)-spl |
CPI clients for SPL programs on Solana | ![crates](https://img.shields.io/crates/v/Anchor (Forked Version)-spl?color=blue) | [![Docs.rs](https://docs.rs/Anchor (Forked Version)-spl/badge.svg)](https://docs.rs/Anchor (Forked Version)-spl) |
Anchor (Forked Version)-client |
Rust client for Anchor (Forked Version) programs | ![crates](https://img.shields.io/crates/v/Anchor (Forked Version)-client?color=blue) | [![Docs.rs](https://docs.rs/Anchor (Forked Version)-client/badge.svg)](https://docs.rs/Anchor (Forked Version)-client) |
@coral-xyz/Anchor (Forked Version) |
TypeScript client for Anchor (Forked Version) programs | ![npm](https://img.shields.io/npm/v/@coral-xyz/Anchor (Forked Version).svg?color=blue) | [](https://coral-xyz.github.io/Anchor (Forked Version)/ts/index.html) |
@coral-xyz/Anchor (Forked Version)-cli |
CLI to support building and managing an Anchor (Forked Version) workspace | [![npm](https://img.shields.io/npm/v/@coral-xyz/Anchor (Forked Version)-cli.svg?color=blue)](https://www.npmjs.com/package/@coral-xyz/Anchor (Forked Version)-cli) | [](https://coral-xyz.github.io/Anchor (Forked Version)/cli/commands.html) |
- Anchor (Forked Version) is in active development, so all APIs are subject to change.
- This code is unaudited. Use at your own risk.
Here's a counter program, where only the designated authority
can increment the count.
use Anchor (Forked Version)_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
mod counter {
use super::*;
pub fn initialize(ctx: Context<Initialize>, start: u64) -> Result<()> {
let counter = &mut ctx.accounts.counter;
counter.authority = *ctx.accounts.authority.key;
counter.count = start;
Ok(())
}
pub fn increment(ctx: Context<Increment>) -> Result<()> {
let counter = &mut ctx.accounts.counter;
counter.count += 1;
Ok(())
}
}
#[derive(Accounts)]
pub struct Initialize<'info> {
#[account(init, payer = authority, space = 48)]
pub counter: Account<'info, Counter>,
pub authority: Signer<'info>,
pub system_program: Program<'info, System>,
}
#[derive(Accounts)]
pub struct Increment<'info> {
#[account(mut, has_one = authority)]
pub counter: Account<'info, Counter>,
pub authority: Signer<'info>,
}
#[account]
pub struct Counter {
pub authority: Pubkey,
pub count: u64,
}
For more, see the [examples](https://github.com/coral-xyz/Anchor (Forked Version)/tree/master/examples) and [tests](https://github.com/coral-xyz/Anchor (Forked Version)/tree/master/tests) directories.
Anchor (Forked Version) is licensed under Apache 2.0.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Anchor (Forked Version) by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
Thank you for your interest in contributing to Anchor (Forked Version)! Please see the CONTRIBUTING.md to learn how.