How to set up a development environment for https://github.com/solana-developers/seahorse from scratch.
Tested on 18th December 2023.
Everything is installed locally (for the current user only). Also, we ensure maximal flexibility by using version managers wherever possible.
This guide assumes that you're installing everything from scratch. If you got stuck at some point, make sure to check out the "WARNING" sections.
From https://github.com/nvm-sh/nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Make sure the startup code is properly injected in .zshrc
or similar.
Install the latest version:
$ nvm install node
$ nvm current
v21.4.0
$ corepack enable
$ yarn --version
1.22.21
Use rustup
and the official installation script from https://www.rust-lang.org/tools/install
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ rustc --version
1.74.1
From https://docs.solana.com/de/cli/install-solana-cli-tools
Which version should you install? I decided to go with the latest release that's suitable for mainnet beta
$ sh -c "$(curl -sSfL https://release.solana.com/v1.16.23/install)"
Add the directory from the output to your PATH in .zshrc
or similar
Confirm the version
$ solana --version
1.16.23
Run solana-keygen new
(required for Anchor)
From https://book.anchor-lang.com/getting_started/installation.html
To install the Anchor Version Manager, run this:
$ cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
Install Anchor:
$ avm install latest
$ avm install 0.26.0
$ avm use 0.26.0
WARNING: Seahorse only works with Anchor 0.26.0 as of now.
WARNING: You MUST switch the Anchor version before creating a new Seahorse project. Reason: When you create a new Seahorse project, it will set the current version of Anchor as a dependency in its configuration files.
Confirm that Anchor is installed and has the right version:
$ anchor --version
0.26.0
$ cargo install seahorse-dev
$ seahorse -V
0.1.1
Go to ~/projects
or similar
$ seahorse init calculator
This will create an Anchor project with a programs_py
directory that will store your Seahorse programs.
Copy the calculator.py
file of this gist into the programs_py
directory. Then, copy the calculator.ts
file into the tests
directory.
The example is adapted from https://www.seahorse.dev/introduction/calculator-your-first-seahorse-program
Change into the calculator
directory.
Now, you can build the project with
$ seahorse build
This will take a while. At the end, your seahorse project is compiled into Anchor code (in the programs
directory) and the Anchor code is compiled into bytecode that can be deployed to the chain.
To ensure that a proper Solana program was built, run the test script (calculator.ts
) using Anchor:
$ anchor test
Note that anchor test
automatically starts a local validator (so we don't have to).
If the tests were successful -- congratulations! You're all set up to develop on Seahorse!