Install Rust

curl --proto '=https' --tlsv1.2 -sSf | sh

Install Solana

sh -c "$(curl -sSfL"

You can also replace beta with stable or any version number.

Setup Solana

solana config set --url localhost

Generate your local key-pair:

solana-keygen new

Store the seed phrase somewhere, if you ever need to recover them.

Install Anchor

Anchor provides several convenient developer tools.

cargo install --git anchor-cli --locked

Install yarn

npm install -g yarn

Create a project

Anchor will scaffold a project.

cd ~/Workspace
anchor init solana-project

Run local ledger

Since during development we will not run on mainnet, we need to run a local ledger/validator. Keep it running.


Build and deploy

anchor build

This will build and output in /target/deploy/. To find the program address, you can run:

solana address -k target/deploy/solana_project-keypair.json

Update this program address for Anchor.toml solana_project and declare_id.

Build again, and deploy this time.

anchor build
anchor deploy


anchor run test

At this point, if you have build and deployed correctly, the tests will pass.




Back to Home