Battery-included Solana/Anchor project skeleton.

Overview

Anchor Skeleton ci

Battery-included Solana/Anchor project skeleton.

Features

  • Rust test only: All tests (integration, unit) are written in Rust, so the compiler will also check them. No Typescript based tests.
  • CI integration: CI automatically deploys the project to Devnet and runs all the tests in Github Action.
  • Feature-based Program ID switch: switch the declare_id in lib.rs based on cargo features: by default, the program_id will be declared in lib.rs (production program-id). If the dev cargo feature is enabled (enabled by default in the Justfile), the declare_id will be the one loaded from programs/contract-skeleton/key.json (dev program-id). You can use just keygen contract-skeleton to generate a new one.
  • Battery included: the skeleton demonstrates the usage of errors, events, examples and integration tests and is immediately deployable and testable.

Prerequisites

For CI:

  • Copy and paste your deployer key (a JSON array, e.g. the content of ~/.config/solana/id.json) into the Github Secret DEPLOY_KEY. There should be some SOL inside the deployer's account; otherwise, CI cannot deploy the project to pay the rent.

Explanation on the Justfile recipes

  • just keygen contract-skeleton: Generate a key.json into the program's folder. Once the dev feature is enabled, the program-id will be the one described in this key.
  • just deploy contract-skeleton: Deploy the contract. Which network to deploy depends on your Solana config (solana config get).
  • just test: Run all the tests locally. just test create_pool to run the create_pool test specifically.
  • just cli: Run the binaries defined in programs/contract-skeleton/examples folder. e.g. just cli create_pool. This command uses the production program-id.
  • just devcli: Run the binaries defined in programs/contract-skeleton/examples folder. e.g. just cli create_pool. This uses the dev program-id.
  • just idl contract-skeleton: generate an idl to target/idl, and populate the program-id using the dev program-id.
  • just dangerously-close contract-skeleton: Close the program and reclaim the rent.

How-tos

  • How do I add a new instruction? First, create a new context file in programs/contract-skeleton/src/contexts.rs. Then create the required account and implement the process method. Finally, add a new method in the lib.rs that calls the process method. Try to make lib.rs clean for someone to know what's included in this program quickly.
  • How do I add a new error type? Add it in programs/contract-skeleton/src/errors.rs.
  • How do I add a new event? Add it at the bottom of the context file because an event usually only gets emitted in one specific instruction.
  • How do I add a new integration test? Add it to the tests folder. Also take a look at the existing tests.
You might also like...
Token management program (vesting and mining) implemented in Anchor
Token management program (vesting and mining) implemented in Anchor

Deep Dive into Anchor by Implementing Token Management Program Author: @ironaddicteddog, @emersonliuuu [Updated at 2022.5.21] You can find the full co

⚓ Solana Sealevel Framework

Anchor ⚓ Anchor is a framework for Solana's Sealevel runtime providing several convenient developer tools. Rust eDSL for writing Solana programs IDL s

Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens;
Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens;

Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens; Starting a variety of auctions for primary/secondary

⛏ An open protocol for launching liquidity mining programs on Solana.
⛏ An open protocol for launching liquidity mining programs on Solana.

⛏ Quarry An open protocol for launching liquidity mining programs on Solana. Background Quarry was built with the intention of helping more Solana pro

A framework for creating PoC's for Solana Smart Contracts in a painless and intuitive way

Solana PoC Framework DISCLAIMER: any illegal usage of this framework is heavily discouraged. Most projects on Solana offer a more than generous bug bo

Generate Nice Solana Address By Template

Yes, I know about GPU generators. https://smith-mcf.medium.com/solana-vanity-address-using-gpus-5a68ad94d1d4 ./solana-nice-address --help solana-nice-

The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime.

Solana Program Library The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime. These programs a

sandbox to play around numerous functionalities on Solana

Solana Sandbox This sandbox is for verifying smart contracts(programs) implemented on Solana for a self-study purpose. Programs Currently implemented

Solana Escrow Program written by RUST.

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

Owner
Weiyuan Wu
In the world without problem formalization, solutions go wild.
Weiyuan Wu
Solana NFT marketplace boilerplate with anchor & react & candy-machine-cli

The Heros NFT Marketplace Boilerplate project is designed to let users fork, customize, and deploy their own nft marketplace app to a custom domain, ultra fast.

null 30 Dec 15, 2022
Solana NFT marketplace boilerplate with anchor & react & candy-machine-cli

Solana_Marketplace_HerosNFT The Heros NFT Marketplace Boilerplate project is designed to let users fork, customize, and deploy their own nft marketpla

null 30 Dec 15, 2022
Write Anchor-compatible Solana programs in TypeScript

Axolotl Write Achor-compatible Solana programs using TypeScript. Writing Rust is hard, but safe. It's also the go-to language for writing Solana progr

Anthony Morris 17 Nov 27, 2022
Keyhouse is a skeleton of general-purpose Key Management System written in Rust.

Keyhouse Keyhouse is a skeleton of general-purpose Key Management System. Keyhouse is not an off-the-shelf system, and it's not ready for production.

Bytedance Inc. 148 Jan 1, 2023
NFT & Marketplace Contracts with royalties and fungible token support. Sample React app included.

NFT Market Reference Implementation A PoC backbone for NFT Marketplaces on NEAR Protocol. Reference Changelog Changelog Progress: basic purchase of NF

NEAR App Examples 156 Apr 28, 2022
Demonstrates Solana data account versioning used in supporting the Solana Cookbook article: Account Data Versioning

versioning-solana This repo demonstrates ONE rudimentary way to upgrade/migrate account data changes with solana program changes. What is data version

Frank V. Castellucci 6 Sep 30, 2022
My attempt at learning Solana program (smart contract) development through RareSkill's Solana course.

60-days-of-solana My attempt at learning Solana program (smart contract) development through RareSkill's Solana course. Originally, I was trying to cr

Jasper 3 Feb 25, 2024
Marinde Anchor-Based, first on mainnet, liquid-staking-program and mSOL->SOL swap pool

marinade-anchor Marinade-finance liquid staking program for the Solana blockchain Audits & Code Review Kudelski Security: https://marinade.finance/Kud

Marinade.Finance 42 Dec 11, 2022
Simple (not simplest) UST vault that integrate with Anchor Protocol

Simple (not simplest) UST Vault Building a simple UST Vault that generate yield from Anchor while also have UST reserved for lending, and etc. This co

Kiettiphong Manovisut 2 May 3, 2022
Anchor Design of contract - Accounts, Parameters

MarketplaceDesign Anchor Design of contract - Accounts, Parameters Main Instructions are Initialize ListForSale AcceptOffer CancelList MakeOffer Cance

James Johnson 8 Sep 1, 2022