Learn Solana in 60 days using the RareSkills Solana Tutorial.
Before you begin, ensure you have the following prerequisites installed. If you already have them, you can skip the respective steps.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
corepack enable
Follow these steps to set up your environment:
Use the stable version for consistency:
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
Anchor is a framework for Solana development, similar to Hardhat.
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
avm install latest
avm use latest
For Mac users, name your program day_(x) instead of day(x).
anchor init day1 # or day_1 for Mac
cd day1
anchor build
Note: Building may take some time depending on your machine and internet connection.
In a new shell (not in the Anchor project directory):
solana config set --url localhost
Open a new shell:
solana-test-validator
Keep the shell running the validator node open.
Return to the shell with the Anchor project and run:
anchor keys sync
Within the Anchor project:
anchor test --skip-local-validator
Note: Follow the instructions from Anchor for setting up a test wallet if needed.
If you encounter issues during installation, please refer to this section.
This tutorial is based on:
Anchor: 0.29.0 Solana: 1.16.25 Rustc: 1.77.0-nightly
For Anchor:
avm install 0.29.0
avm use 0.29.0
For Solana:
sh -c "$(curl -sSfL https://release.solana.com/1.16.25/install)"
If you encounter errors like:
error: package
solana-program v1.18.0 cannot be built
This might be due to a Rust version mismatch. Ensure you are using Rustc version 1.72.0 or newer, or adjust your Solana program version accordingly.
Check your Solana version:
solana --version
Then update the Solana program version:
cargo update -p [email protected] --precise [version]
Replace [version] with the appropriate version number.
Note: Your [email protected]
version may be higher, make sure youse use the program version you're using, plus the returned Solana version from the above step.