Solana CLI Basics
10 examples to get you started with the Solana CLI - 7 basic and 3 intermediate.
Prerequisites
Install the Agave toolchain (Solana CLI 3.0.10 ships with Agave 4.1.1):
sh -c "$(curl -sSfL https://release.anza.xyz/v4.1.1/install)"
solana --version
# solana-cli 3.0.10Add the install directory to your PATH if the installer prompts you. You need a default keypair before sending transactions - see Keypairs with solana-keygen.
Basic Examples
1. Check CLI Version
Confirm the CLI and cluster tooling match your pinned stack.
solana --version
agave-install --version- Prints
solana-cli 3.0.10when aligned with Agave 4.1.1. - Mismatched versions cause subtle RPC and deploy errors.
- Pin versions per project with
agave-install(see Version Management).
Related: Toolchain Overview - how the pieces fit together
2. View Current Config
See which RPC URL, keypair, and commitment level the CLI uses.
solana config getRPC URLis where every command sends JSON-RPC requests.Keypair Pathis the signing identity for transfers and deploys.Commitmentdefaults toconfirmed- good for dev workflows.
Related: RPC Basics - commitment levels explained
3. Point at Devnet
Switch the CLI to Solana's public devnet for free airdrops and testing.
solana config set --url devnet
solana config getdevnetresolves to the public devnet RPC endpoint.- Devnet SOL has no real value - reset your expectations for balances.
- Use
mainnet-betaonly when you intend to spend real SOL.
Related: Airdrops & Balances - fund your dev wallet
4. Point at Localnet
Target a solana-test-validator instance on your machine.
solana config set --url http://127.0.0.1:8899
solana config get- Port
8899is the default JSON-RPC port forsolana-test-validator. - Localnet gives deterministic, fast iteration with no rate limits.
- Reset config back to devnet when you finish local work.
Related: solana-test-validator - start a local cluster
5. Set Default Keypair
Tell the CLI which keypair signs outgoing transactions.
solana config set --keypair ~/.config/solana/id.json
solana addresssolana addressprints the public key derived from the keypair file.- Never commit keypair JSON files to git.
- Use separate keypairs per environment (local, devnet, mainnet).
Related: Keypairs with solana-keygen - generate and recover keys
6. Check Wallet Balance
Read lamports for the configured keypair.
solana balance
solana balance <PUBKEY>- Balance is shown in SOL; internally the chain stores lamports (1 SOL = 10^9 lamports).
- Zero balance blocks transaction fees - airdrop on devnet first.
- Use a specific pubkey to inspect any account, not just your default.
Related: Airdrops & Balances - request devnet SOL
7. Inspect Cluster Health
Verify the RPC endpoint is reachable and producing slots.
solana cluster-version
solana slotcluster-versionconfirms the validator software version on the cluster.slotreturns the current slot - if it stalls, your RPC may be unhealthy.- Compare slot progression across two calls to detect a stuck endpoint.
Related: RPC Providers - when to use a dedicated RPC
Intermediate Examples
8. Custom RPC with API Key
Route the CLI through a provider URL while keeping the same commands.
solana config set --url "https://devnet.helius-rpc.com/?api-key=YOUR_KEY"
solana config get
solana slot- Provider URLs add rate-limit headroom and better uptime than public endpoints.
- Store API keys in environment variables, not shell history.
- The CLI does not cache responses - every command hits the configured URL.
Related: RPC Providers - provider trade-offs
9. Set Commitment Level
Tune how finalized a read must be before the CLI returns.
solana config set --commitment finalized
solana config getprocessedis fastest but can roll back on forks.confirmedis the default sweet spot for dev and most scripts.finalizedis safest for treasury operations but slower.
Related: RPC Basics - commitment semantics
10. Export Config for Scripts
Capture settings so CI and teammates use the same cluster and keypair.
solana config get --json > solana-config.json
cat solana-config.json- JSON output is machine-readable for automation pipelines.
- Do not check keypair paths with production keys into shared repos.
- Pair exported config with
agave-installversion pins for reproducibility.
Related: Solana CLI Best Practices - repeatable team workflows
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.