This document provides detailed run instructions for building the program and running tests (at least). It includes steps to set up the environment and handle common issues and gotchas.
- Rust (version rustc 1.73.0)
- Solana (version 1.16.18)
- Node.js (latest stable version)
- Yarn (latest stable version)
- Anchor (follow instructions from the Anchor documentation)
- Download and install
rustup
by running:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Follow the on-screen instructions to complete the installation.
- After installation, install the specific Rust version (rustc 1.73.0):
rustup install 1.73.0 rustup default 1.73.0
- Install Solana using the
solana-install
tool:sh -c "$(curl -sSfL https://release.solana.com/v1.16.18/install)"
- Add Solana to your PATH following the instructions provided at the end of the installation process.
- Install Node.js from Node.js official website or use a version manager like
nvm
. - Install Yarn globally using npm:
npm install -g yarn
- Follow the detailed installation instructions for Anchor provided in the Anchor documentation.
- install cargo if you don't already have it:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Install solana-verifiable-build using
cargo
:cargo install solana-verify
After setting up the environment and installing all prerequisites, run the following commands in your project directory:
- Build the project using Anchor:
anchor build
- Run tests with Anchor:
anchor test
- If you encounter any issues with version mismatches, ensure that the installed versions match the required versions listed in the prerequisites.
- For any errors related to dependencies, try running
yarn install
in the project directory to ensure all necessary packages are installed.
- You have the latest rustc version istalled but
anchor build
still complains that you have an old rust version installed... something like this (below). This means you need to update your solana version as documented above.
error: package regex-automata v0.4.3 cannot be built because it requires rustc 1.65 or newer, while the currently active rustc version is 1.62.0-dev
- Install dependencies in root and sdk sub directory:
yarn install (cd sdk && yarn install)
- Run all tests with anchor:
anchor test
- Run a specific test in the
test.sh
shell script:./test.sh <test_name>