read

Install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Install Solana

sh -c "$(curl -sSfL https://release.solana.com/beta/install)"

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 https://github.com/project-serum/anchor 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.

solana-test-validator

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 lib.rs declare_id.

Build again, and deploy this time.

anchor build
anchor deploy

Test

anchor run test

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


Image

@samwize

¯\_(ツ)_/¯

Back to Home