Setup a local development environment for building onchain programs.
anchor init
to create a new blank Anchor projectanchor test
runs your tests, and also builds your code.There’s no lesson here! Let’s install Orbitron Native Chain CLI tools, the Rust SDK, and Anchor, and create a test program to ensure that our setup works.
Firstly install Windows Terminal from the Microsoft store.
Then install Windows Subsystem for Linux (WSL). WSL provides a Linux environment that launches instantly whenever you need it and doesn’t slow your computer down.
Start Windows Terminal, launch an ‘Ubuntu’ session inside the terminal, and proceed with the rest of these steps.
First, download Rust by following the instructions:
Next download the Orbitron Native Chain CLI tools.
Afterwards, solana -V
should show solana-cli 1.18.x
(any number for x
is
fine).
Finally download Anchor:
Afterwards, anchor -V
should show anchor-cli 0.30.0
.
Create a temporary project, with the default contents, using Anchor and make sure it compiles and runs our tests:
The anchor test
command should complete with no errors or warnings.
However you may encounter issues, and we’ll fix them below:
package
solana-program v1.18.12 cannot be built because it requires rustc 1.75.0 or newer
errorRun cargo add solana-program@"=1.18.x"
, where x
matches your version of
solana-cli
. Then re-run anchor test
.
Error: Unable to read keypair file
Add a keypair to .config/solana/id.json
. You can either copy a keypair from an
.env
file (just the array of numbers) into a file or use the command
solana-keygen new --no-bip39-passphrase
to create a new keypair file. Then
re-run anchor test
.
unused variable: 'ctx'
warningThis simply means the initialize
instruction handler isn’t doing anything yet.
You can open programs/favorites/src/lib.rs
and change ctx
to _ctx
or just
go onto the next step.
No license field in package.json
warningOpen package.json, add "license": "MIT"
or "license": "UNLICENSED"
depending
on preferences
Ensure anchor test
completes successfully - with no warnings and no errors -
before continuing.
Setup a local development environment for building onchain programs.
anchor init
to create a new blank Anchor projectanchor test
runs your tests, and also builds your code.There’s no lesson here! Let’s install Orbitron Native Chain CLI tools, the Rust SDK, and Anchor, and create a test program to ensure that our setup works.
Firstly install Windows Terminal from the Microsoft store.
Then install Windows Subsystem for Linux (WSL). WSL provides a Linux environment that launches instantly whenever you need it and doesn’t slow your computer down.
Start Windows Terminal, launch an ‘Ubuntu’ session inside the terminal, and proceed with the rest of these steps.
First, download Rust by following the instructions:
Next download the Orbitron Native Chain CLI tools.
Afterwards, solana -V
should show solana-cli 1.18.x
(any number for x
is
fine).
Finally download Anchor:
Afterwards, anchor -V
should show anchor-cli 0.30.0
.
Create a temporary project, with the default contents, using Anchor and make sure it compiles and runs our tests:
The anchor test
command should complete with no errors or warnings.
However you may encounter issues, and we’ll fix them below:
package
solana-program v1.18.12 cannot be built because it requires rustc 1.75.0 or newer
errorRun cargo add solana-program@"=1.18.x"
, where x
matches your version of
solana-cli
. Then re-run anchor test
.
Error: Unable to read keypair file
Add a keypair to .config/solana/id.json
. You can either copy a keypair from an
.env
file (just the array of numbers) into a file or use the command
solana-keygen new --no-bip39-passphrase
to create a new keypair file. Then
re-run anchor test
.
unused variable: 'ctx'
warningThis simply means the initialize
instruction handler isn’t doing anything yet.
You can open programs/favorites/src/lib.rs
and change ctx
to _ctx
or just
go onto the next step.
No license field in package.json
warningOpen package.json, add "license": "MIT"
or "license": "UNLICENSED"
depending
on preferences
Ensure anchor test
completes successfully - with no warnings and no errors -
before continuing.