Solana CLI Cheatsheet for Beginners and Power Users

Solana CLI Cheatsheet for Beginners and Power Users

While graphical user interfaces (GUIs) and web apps are great, true power, speed, and automation on Solana come from the command line. The Solana Command-Line Interface (CLI) is the single most important tool in any serious developer’s, staker’s, or power user’s arsenal. It allows you to interact directly with the blockchain, manage assets, and deploy programs without ever leaving your terminal.

This cheatsheet is designed to be your definitive, one-stop reference. We’ve organized it logically, starting with the absolute essentials for beginners and progressing to more advanced commands for developers and validators. Bookmark this page—you’ll be coming back to it often.

Section 1: The Absolute Essentials (For Beginners)

These are the first commands you should learn to orient yourself.

  • Check Installation & Version: Verify that the CLI is installed and see which version you’re running.
    solana --version 
  • Configure the Network (Cluster): Tell the CLI which Solana network you want to talk to.
    # Connect to Mainnet solana config set --url https://api.mainnet-beta.solana.com # Connect to Devnet solana config set --url https://api.devnet.solana.com # Connect to a local test validator solana config set --url http://localhost:8899 
  • View Current Configuration: See which network and wallet you are currently configured to use.
    solana config get 
  • Get Free Devnet SOL (Airdrop): You’ll need SOL to pay for transaction fees on Devnet or Testnet.
    solana airdrop 2 

 

Section 2: Wallet and Keypair Management

These commands are for managing your identities and funds.

  • Create a New File-System Wallet: Generates a new keypair and saves it to a JSON file.
    solana-keygen new --outfile ~/.config/solana/my-new-wallet.json 
  • Check Your Current Wallet Address: Displays the public key of the keypair currently set in your config.
    solana address 
  • Check the SOL Balance of a Wallet: Check your default wallet’s balance, or specify an address.
    # Check default wallet solana balance # Check a specific address solana balance <RECIPIENT_ADDRESS> 
  • Transfer SOL: Send SOL from your default wallet to another address.
    solana transfer <RECIPIENT_ADDRESS> <AMOUNT> 

 

Section 3: Interacting with the Network

Commands for querying blockchain state and transaction history.

  • Confirm a Transaction: Check the status of a transaction and see its logs. The -v flag adds verbosity.
    solana confirm -v <TRANSACTION_SIGNATURE> 
  • Get Block Information: View the contents of a specific block (slot).
    solana block <SLOT_NUMBER> 
  • Get Current Epoch Information: See information about the current epoch, slot height, and more.
    solana epoch-info 

 

Section 4: The SPL Token CLI (For All Token Interactions)

To interact with SPL Tokens (like USDC, or any meme coin), you use the spl-token command suite.

  • Create a New Token Type (Mint): This creates the “master record” for a new token.
    spl-token create-token 
  • Create an Account for a Token: Before you can hold a token, you need an account for it.
    spl-token create-account <TOKEN_ADDRESS> 
  • Mint New Tokens: Create new tokens (only possible if you have mint authority).
    spl-token mint <TOKEN_ADDRESS> <AMOUNT> 
  • Check a Token Balance: Check how many of a specific token are in your associated token account.
    spl-token balance <TOKEN_ADDRESS> 
  • Transfer Tokens: Send SPL tokens to another person’s main wallet address (the CLI handles finding their token account).
    spl-token transfer <TOKEN_ADDRESS> <AMOUNT> <RECIPIENT_WALLET_ADDRESS> 
  • Disable Mint Authority: A crucial step for token creators to build trust by making the supply fixed.
    spl-token authorize <TOKEN_ADDRESS> mint --disable 

 

Section 5: For Developers & Power Users

Commands for deploying and managing on-chain programs.

  • Deploy a Program: Uploads your compiled program (.so file) to the blockchain.
    solana program deploy /path/to/your/program.so 
  • Show Program Details: View information about a deployed program, like its owner and data size.
    solana program show <PROGRAM_ID> 
  • Close an Empty Account & Reclaim Rent: If an account is no longer needed, you can close it to get back the SOL that was used to pay its “rent.”

 

Section 6: For Stakers & Validators (Advanced)

A few key commands for those participating in securing the network.

  • Create a Stake Account: Creates a new account specifically for staking SOL.
    solana create-stake-account <STAKE_ACCOUNT_KEYPAIR>.json <AMOUNT> 
  • Delegate Stake to a Validator: Assigns the SOL in your stake account to a validator to start earning rewards.
    solana delegate-stake <STAKE_ACCOUNT_ADDRESS> <VOTE_ACCOUNT_ADDRESS> 
  • View Current Validators: Get a list of all active validators and their commission rates.
    solana validators 

 

Pro Tips and Tricks

  • Specify a Wallet for Any Command: Use the --keypair flag to run any command with a wallet other than your default.
    solana transfer <RECIPIENT> 1 --keypair ~/my-other-wallet.json 
  • Get Machine-Readable Output: Add --output json or --output json-compact to any command to get JSON output, perfect for scripting and automation.
  • Explore Any Command: Use the --help flag on any command (e.g., solana transfer --help or spl-token --help) to see all its available options and arguments. It’s the best way to discover advanced features.

Leave a Comment