Update and add dependencies (for linux)
sudo apt update && upgrade
sudo apt-get install -y \
build-essential \
pkg-config \
libudev-dev llvm libclang-dev \
protobuf-compiler libssl-dev
Install Rust
Rust is required to build Solana programs.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After installation, add Rust to your path:
source $HOME/.cargo/env
To update Rust, run:
rustup update
Verify Rust Installation
Check the installed version of Rust:
rustc --version
Install Solana CLI
To install the Solana command-line tools, run:
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
(then add it to the PATH)
To update Solana, run:
solana-install update
Verify Solana Installation
Check the installed version of Rust:
solana --version
Install Anchor
Install Anchor CLI using Anchor version manager:
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
then:
avm install latest
avm use latest
Verify Anchor Installation
Check the installed version of Rust:
anchor --version
Trouble Shooting (adapt to the correct versions)
cargo build-sbf --tools-version v1.39
solana-install init 1.18.17
solana --version
cargo update -p solana-program@1.18.17 --precise {the solana version}
Common Commands
-
Get the cluster configuration:
solana config get
-
Set the cluster (e.g., devnet, testnet, mainnet):
solana config set --url https://api.devnet.solana.com
-
Create a new wallet:
solana-keygen new
-
Get the current wallet:
solana-keygen pubkey
-
Check wallet balance:
solana balance <optional address>
-
Airdrop SOL (for devnet):
solana airdrop 1 <optional address>
Common Commands
-
Initialize a new Anchor project:
anchor init my_project
-
Get the cluster list
anchor cluster list
-
Build the Anchor program:
anchor build
-
Deploy the Anchor program:
anchor deploy
-
Test the program:
anchor test
-
Upgrade the program:
anchor upgrade <target/deploy/program.so> --program-id <program-id>
- Create a new project:
npx create-solana-dapp@latest