はじめに

Solana CLI Essentials

A guide to the essential Solana command-line interface (CLI) commands you'll need for development.

What You'll Learn

  • How to install and configure the Solana CLI
  • Essential commands for daily development
  • How to switch between clusters (devnet, testnet, mainnet)
  • When to use Solana CLI vs MPLX CLI

Prerequisites

  • Basic command-line familiarity
  • Node.js 16+ installed (for MPLX CLI)

Installation

Solana CLI

Install the Solana CLI tools using the official installer.

Installation Commands

sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"

After installation, restart your terminal and verify:

solana --version

For Metaplex-specific operations like creating tokens with metadata, NFTs, and Candy Machines, the MPLX CLI provides a streamlined experience with interactive wizards. This requires you to have npm/node installed. If you do not have it yet follow your operating system specific guide on the Node.js Download Page.

npm install -g @metaplex-foundation/cli
mplx --version

When to Use Which CLI

TaskRecommended CLI
Grinding keypairsSolana CLI
Check balancesEither (MPLX: mplx toolbox sol-balance)
Transfer SOLEither (MPLX: mplx toolbox sol-transfer)
Airdrop devnet SOLEither (MPLX: mplx toolbox sol-airdrop)
Create tokens with metadataMPLX CLI (mplx toolbox token-create)
Create NFTs/CollectionsMPLX CLI (mplx core create-asset)
Candy Machine operationsMPLX CLI (mplx cm)
Deploy custom programsSolana CLI
Low-level transactionsSolana CLI

Configuration

View Current Configuration

solana config get

This displays your current settings including:

  • Config File - Location of your config file
  • RPC URL - The cluster you're connected to
  • WebSocket URL - For subscription-based updates
  • Keypair Path - Your default wallet location

Set Your Wallet

Point the CLI to your keypair file:

solana config set --keypair ~/.config/solana/id.json

Or use a specific keypair:

solana config set --keypair /path/to/my-wallet.json

Switch Clusters

Change which Solana network you're connected to:

# Devnet (for development and testing)
solana config set --url devnet
# Testnet (for testing with more realistic conditions)
solana config set --url testnet
# Mainnet (production - real SOL!)
solana config set --url mainnet-beta
# Local validator
solana config set --url localhost

You can also use full URLs:

solana config set --url https://api.devnet.solana.com

Essential Commands

Check Your Balance

# Using configured wallet
solana balance
# Check a specific address
solana balance <ADDRESS>
# With MPLX CLI
mplx toolbox sol-balance
mplx toolbox sol-balance <ADDRESS>

Request Airdrop (Devnet/Testnet Only)

# Airdrop 1 SOL to your wallet
solana airdrop 1
# Airdrop to a specific address
solana airdrop 1 <ADDRESS>
# With MPLX CLI
mplx toolbox sol-airdrop 1
mplx toolbox sol-airdrop 1 --to <ADDRESS>

Airdrop Limits

Devnet airdrops are limited to 2 SOL per request with rate limiting. If airdrops fail, wait a few minutes or try a web faucet.

Transfer SOL

# Transfer SOL to another address
solana transfer <RECIPIENT_ADDRESS> <AMOUNT>
# With MPLX CLI
mplx toolbox sol-transfer <RECIPIENT_ADDRESS> <AMOUNT>

View Account Information

# View account details
solana account <ADDRESS>
# View in JSON format
solana account <ADDRESS> --output json

Check Transaction Status

# Confirm a transaction
solana confirm <SIGNATURE>
# Get transaction details
solana transaction-history <ADDRESS>

View Cluster Information

# Check cluster version
solana cluster-version
# View current slot
solana slot
# Check cluster health
solana catchup --our-localhost

Working with Programs

View Program Information

# Get program account info
solana program show <PROGRAM_ID>

Download a Program

Useful for local validator testing:

solana program dump -u mainnet-beta <PROGRAM_ID> program.so

Practical Examples

Daily Development Workflow

# 1. Start your day - check config
solana config get
# 2. Make sure you're on devnet
solana config set --url devnet
# 3. Check your balance
solana balance
# 4. Need SOL? Airdrop some
solana airdrop 2
# 5. Verify the airdrop
solana balance

Common Issues

"Unable to connect to cluster"

Your RPC endpoint may be down or rate-limited. Try:

# Switch to a different RPC
solana config set --url https://api.devnet.solana.com

"Keypair file not found"

Generate a new keypair or point to an existing one:

# Generate new keypair
solana-keygen new --outfile ~/.config/solana/id.json
# Or set path to existing keypair
solana config set --keypair /path/to/existing/keypair.json

Commands Running Slowly

You may be rate-limited. Consider using a dedicated RPC provider like Helius, QuickNode, or Triton for better performance.

Next Steps

FAQ

What's the difference between Solana CLI and MPLX CLI?

The Solana CLI is the official tool for general Solana operations (wallets, transfers, program deployment). The MPLX CLI is Metaplex's tool specifically for NFTs, tokens with metadata, and Candy Machines. Use Solana CLI for low-level operations and MPLX CLI for Metaplex-specific tasks.

Can I use multiple keypairs?

Yes. Either specify the keypair per command with --keypair flag, or change your default with solana config set --keypair. The MPLX CLI also supports multiple wallets via mplx config wallets.

How do I know which cluster I'm connected to?

Run solana config get - the "RPC URL" line shows your current cluster. Devnet URLs contain "devnet", mainnet contains "mainnet-beta".