🌟 A Solana Cheatsheet for Easy Copy & Paste for Busy Devs. 👻
solana --version
: Get the version of Solana CLI.solana cluster-version
: Get the version of the Solana cluster that you are currently set to. Ensure the local CLI version is greater than or equal to the cluster version.solana config get
: Get current RPC URL of the connected Solana cluster and show key pair path to your local wallet.solana config set --url https://api.devnet.solana.com
: Set the Solana cluster to devnet.solana airdrop 10
: Get 10 SOL for free to your default wallet locally! (Of course not available on mainet XD)solana balance
: Check your current SOL balance in the default wallet.echo 'export RUST_LOG=solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=info,solana_bpf_loader=debug,solana_rbpf=debug' >> ~/.bashrc
: Enable Rust logs for debugging.solana-test-validator --log
: Start a single node Solana cluster with logs. Note that a folder namedtest-ledger
will be created to store the local cluster data in the directory you run this command. Leave this node running in a spare terminal. See more in the docs.solana config set --url http://127.0.0.1:8899
: Set Solana CLI to interact with local cluster on port 8899.solana logs -u localhost
: Show the explicit logs when you interact with the Solana smart contracts.solana program deploy <your_program_path>
: Deploy smart contracts on the current Solana cluster.- add
--final
at the end of this command to make the program immutable and cannot be redeployed.
- add
solana program show <account_address>
: Get the information of a deployed program.solana program deploy --max-len 200000 <your_program_path>
: When redeploying a program, if the program size of the previous version is more than 2x smaller than the new version, we need to specify the smallest size in bytes that the program is expected to have. Otherwise, the redeployment may fail. Note thatmax-len
can only be set during the initial deployment.solana-install update
: Update Solana CLI version
rustup default nightly
: Change Rust to nightly versionrustup default stable
: Change Rust to stable versionrustup update
: Update Rust to latest version
cargo install --git https://github.com/project-serum/anchor anchor-cli --locked
: Update the anchor CLI to the lastest version.