Basic Anchor Smart Contracts
This is a beta version of the Solana Toolkit, and is still a WIP. Please post all feedback as a GitHub issue here.
Overview
This initializes a simplistic workspace set up for Anchor smart contract development, with the following structure:
Anchor.toml
: Anchor configuration file.Cargo.toml
: Rust workspace configuration file.package.json
: JavaScript dependencies file.programs/
: Directory for Solana program crates.app/
: Directory for your application frontend.tests/
: Directory for JavaScript integration tests.migrations/deploy.js
: Deploy script.
The Anchor framework abstracts away many complexities enabling fast program development.
Build and Test
To test out this project before making any modifications, just build and test:
To start writing your own Anchor smart contract, navigate to
programs/src/lib.rs
.
File Structure Template
For more complex programs, using a more structured project template would be the best practice. This can be generated with:
Which creates the following layout inside of programs/src
:
For project file structure best practices, review this document.