GithubHelp home page GithubHelp logo

woniesong92 / anchor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from coral-xyz/anchor

0.0 2.0 0.0 4.21 MB

⚓ Solana Sealevel Framework

Home Page: https://project-serum.github.io/anchor

License: Apache License 2.0

Rust 68.93% JavaScript 18.92% TypeScript 11.27% Shell 0.43% Makefile 0.30% Dockerfile 0.15%

anchor's Introduction

Anchor ⚓

Build Status Docs Chat License

Anchor is a framework for Solana's Sealevel runtime providing several convenient developer tools.

  • 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 or Parity's Ink!, 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.

Getting Started

For a quickstart guide and in depth tutorials, see the guided documentation. To jump straight to examples, go here. For the latest Rust and TypeScript API documentation, see docs.rs and the typedoc.

Packages

Package Description Version Docs
anchor-lang Rust primitives for writing programs on Solana Crates.io Docs.rs
anchor-spl CPI clients for SPL programs on Solana crates Docs.rs
anchor-client Rust client for Anchor programs crates Docs.rs
@project-serum/anchor TypeScript client for Anchor programs npm Docs

Note

  • Anchor is in active development, so all APIs are subject to change.
  • This code is unaudited. Use at your own risk.

Examples

Here's a counter program, where only the designated authority can increment the count.

use anchor_lang::prelude::*;

#[program]
mod counter {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>, start: u64) -> ProgramResult {
        let counter = &mut ctx.accounts.counter;
        counter.authority = *ctx.accounts.authority.key;
        counter.count = start;
        Ok(())
    }

    pub fn increment(ctx: Context<Increment>) -> ProgramResult {
        let counter = &mut ctx.accounts.counter;
        counter.count += 1;
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(init, payer = authority, space = 48)]
    pub counter: ProgramAccount<'info, Counter>,
    #[account(signer)]
    pub authority: AccountInfo<'info>,
    #[account(address = system_program::ID)]
    pub system_program: AccountInfo<'info>,
}

#[derive(Accounts)]
pub struct Increment<'info> {
    #[account(mut, has_one = authority)]
    pub counter: ProgramAccount<'info, Counter>,
    #[account(signer)]
    pub authority: AccountInfo<'info>,
}

#[account]
pub struct Counter {
    pub authority: Pubkey,
    pub count: u64,
}

For more, see the examples directory.

Contribution

Thank you for your interest in contributing to Anchor! All contributions are welcome no matter how big or small. This includes (but is not limited to) filing issues, adding documentation, fixing bugs, creating examples, and implementing features.

If you'd like to contribute, please claim an issue by commenting, forking, and opening a pull request, even if empty. This allows the maintainers to track who is working on what issue as to not overlap work. If you're looking to get started, check out good first issues or issues where help is wanted. For simple documentation changes, feel free to just open a pull request.

If you're considering larger changes or self motivated features, please file an issue and engage with the maintainers in Discord.

When contributing, please make sure your code adheres to some basic coding guidlines:

  • Code must be formatted with the configured formatters (e.g. rustfmt and prettier).
  • Comment lines should be no longer than 80 characters and written with proper grammar and punctuation.
  • Commit messages should be prefixed with the package(s) they modify. Changes affecting multiple packages should list all packages. In rare cases, changes may omit the package name prefix.
  • All notable changes should be documented in the Change Log.

License

Anchor is licensed under Apache 2.0.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Anchor by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

anchor's People

Contributors

armaniferrante avatar fanatid avatar johnrees avatar dependabot[bot] avatar johndoe389 avatar michaelhly avatar norbertbodziony avatar suscd avatar henry-e avatar badass-commits avatar bonedaddy avatar guanqun avatar jon-chuang avatar austinabell avatar jackson-sandland avatar mschneider avatar standaa avatar defactojob avatar h4rkl avatar keemy avatar skrrb avatar ariskk avatar dahifi avatar buzzec avatar brson avatar canardmandarin avatar crispheaney avatar thesoftwarejedi avatar billythedummy avatar macalinao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.