Skip to content

Instantly share code, notes, and snippets.

@BlockByBlock
Last active October 20, 2021 18:11
Show Gist options
  • Save BlockByBlock/9a4e745cd327950e7e914b2a479df2fa to your computer and use it in GitHub Desktop.
Save BlockByBlock/9a4e745cd327950e7e914b2a479df2fa to your computer and use it in GitHub Desktop.
For serum anchor

For Mac M1 installation with issue try updating rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup component add rustfmt

Install anchor and anchor-cli

cargo install --git https://github.com/project-serum/anchor --tag v0.17.0 anchor-cli --locked
# installing via npm causes issue

Build

anchor build

Update config

$ solana address -k ./target/deploy/<app-name>-keypair.json
# update lib.rs declare_id()
# update Anchor.toml [programs.localnet]
# top up test wallet with token - solana airdrop 1
# update Anchor.toml [provider] wallet 

Fix for Mac M1: coral-xyz/anchor#95 (comment) Following the instructions here, but not running solana-install init worked:

https://docs.solana.com/cli/install-solana-cli-tools#build-from-source

Then go to sdk/cargo-build-bpf from the project root. From there, run the following:

$ cargo install --path .

This will install the cargo-build-bpf program to ~/.cargo/bin. Next in ~/.cargo/bin create a symlink to the sdk folder in the project’s bin folder, like this:

$ ln -s $PROJECT_ROOT/bin/sdk ~/.cargo/bin/sdk

Replace $PROJECT_ROOT with your Solana project folder.

Test

$ anchor test

For resolving file not found, add npx to test in Anchor.toml e.g. test = "npx mocha -t 1000000 ./tests/"

Deploy

$ anchor deploy
$ solana program show <ACCOUNT_ADDRESS>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment