Solana Program Scaffold

This is a beta version of the Solana Toolkit, and is still a WIP. Please post all feedback as a GitHub issue here.

pnpm create solana-program

create-solana-program initializes an in-depth workspace with everything you need for general Solana program development. This scaffold allows you to write either native rust programs or Anchor programs.

Program Frameworks

After running this command, you'll have the option to choose between Shank and Anchor for the program framework:

  • Shank creates a vanilla Solana smart contract with Shank macros to generate IDLs. For more information on Shank, read its README.

  • Anchor creates a smart contract using the Anchor framework, which abstracts away many complexities enabling fast program development. For more information on the Anchor framework, read the Anchor book.

Anchor framework

For Anchor rust development, chose Anchor when asked which program framework to use. This will create a basic Anchor counter program with the following project structure for your program:

├── program.rs
   ├── src.rs
   ├── lib.rs
   ├── Cargo.toml
   ├── keypair.json
   ├── README.md

Native rust

For native rust development, make sure you chose Shank when asked which program framework to use. This will create a basic counter program with the following project structure for your program:

├── program.rs
   ├── src.rs
   ├── assertions.rs
   ├──entrypoint.rs
   ├──error.rs
   ├──instruction.rs
   ├──lib.rs
   ├──processor.rs
   ├──state.rs
   ├──utils.rs
   ├── Cargo.toml
   ├── keypair.json
   ├── README.md

Generated Clients

Next, you'll have the option to choose between a JavaScript client, a Rust Client, or both.

  • JavaScript Client creates a typescript library compatible with web3.js.

  • Rust Client creates a rust crate allowing consumers to interact with the program.

For further workspace customization and additional information, check out the create-solana-program README.

Build

After answering the above prompts, the workspace will be generated. To get started, build your program and clients by running:

cd <my-program-name>
npm install
npm run generate

To update an existing Anchor project to have this scaffold, read this guide.

Additional Resources

Last updated on

Tabla de Contenidos

Editar Página