Try   HackMD

Solana deploy cheatsheet

This doc lets you go from zero to deployed on testnet in <15 minutes.

Install requirements (MacOS and WSL2)

System dependencies

Install system dependencies (Linux & WSL2)

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev

Rust

Install Rust

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

Check for updates (if you have an older install)

rustup check

Install updates

rustup update

Solana CLI

Install the CLI

# Can replace "stable" with "beta", "edge" or exact version (ex "v1.10.31")
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

Check version

solana --version

Anchor

Install Anchor Version Manager

cargo install --git https://github.com/project-serum/anchor avm --locked --force

Install anchor

avm install latest
avm use latest

Check Anchor version

anchor --version

Issues and debugging

If the version of anchor-cli doesn't show as the latest after avm use latest, you might have an older version installed with NPM, you can find it with

npm -g ls

If you see @project-srum/anchor-cli in the list, you can remove it with:

npm -g uninstall @project-serum/anchor-cli
npm -g uninstall @project-serum/anchor

Set up Anchor with AVM using:

avm use latest

Update your terminal with

# If using bash
source ~/.bashrc

# If using zsh (Zshell)
source ~/.zshrc

Set up environment

Set up Solana keypair

Generate a new keypair

solana-keygen new

Passphrase not necessary but highly recommended for mainnet deployments. Check file system wallet commands here.

Set network to devnet

solana config set --url devnet

Options for url flag: mainnet-beta, testnet, devnet, localhost or m, t, d, l

Get testnet SOL

solana airdrop 2

Check balance

solana balance

Print address

solana address

View Solana config

Solana config get

Create Anchor project

Create a new anchor project (remove the js flag if u want ts)

anchor init PROJECT_NAME_HERE --javascript

Test that everything is working with

# navigate into project folder
cd glass-generator

# Run the built in test
anchor test

This may take a while, as long as it says "1 passing" near the bottom, you're ready to proceed.

Chew glass

After adding contract code to src/lib.rs in the programs folder, fetch address with

anchor build
anchor keys list

Finall, you can deploy with

anchor deploy 

Issues and debugging

TBA
Call ur mom
Go to sleep
Run the same command again without any changes