The Solana Command Line Interface (CLI) offers a powerful way to manage your digital assets. This guide covers the primary wallet types and the essential operations you can perform using Solana CLI tools, helping you interact with the blockchain efficiently and securely.
Understanding Solana CLI Wallet Types
Solana CLI supports several wallet types, each with distinct security and usability characteristics. Choosing the right one depends on your specific needs for security, convenience, and use case.
File System Wallet (FS Wallet)
A File System Wallet stores an unencrypted keypair in a JSON file on your computer's local storage. The Solana CLI requires you to specify the file path for every operation. While convenient for frequent transactions, this method is less secure than other options because the private key is stored in plain text. If someone gains access to this file, they could gain control of your funds.
Creating a File System Wallet
To generate a new File System Wallet, use the solana-keygen new command with the --outfile flag to specify where to save the keypair file.
solana-keygen new --outfile ~/my-solana-fs-wallet-keypair.jsonThe command will generate a new keypair, display the public key (your wallet address), and provide a BIP39 seed phrase for recovery. You must save this seed phrase securely; it is your only way to restore access if the file is lost.
Important Security Note: Never share this keypair file online. Anyone with access to it can transfer your assets. Always keep your seed phrase confidential and secure.
Checking the Wallet's Public Key
You can retrieve the public key (your wallet address) from the keypair file at any time.
solana-keygen pubkey ~/my-solana-fs-wallet-keypair.jsonVerifying the Keypair File
It's good practice to verify that the public key matches the keypair stored in the file.
solana-keygen verify <PUBLIC_KEY> ~/my-solana-fs-wallet-keypair.jsonThe command will return Success if the verification is successful or Failed if there is a mismatch.
Recovering a Wallet from a Seed Phrase
If you lose your keypair file, you can recover the wallet using your saved seed phrase.
solana-keygen recover --outfile ~/my-solana-fs-wallet-keypair.jsonYou will be prompted to enter your seed phrase and any associated BIP39 passphrase. After confirmation, a new keypair file will be generated. You can compare the recovered file with a backup to ensure consistency.
Paper Wallet
A Paper Wallet is a type of "cold wallet" where the keypair is not stored digitally on a file system. Instead, all key information is generated and displayed on-screen, and you must physically record it—typically on paper—hence the name. This method is considered more secure against digital theft but requires careful physical safeguarding of the seed phrase.
Creating a Paper Wallet
Use the solana-keygen new command with the --no-outfile flag to generate a keypair without creating a file.
solana-keygen new --no-outfileThe command will output the public key and the seed phrase to your terminal. You must manually and securely record this information.
Retrieving the Public Key from a Seed Phrase
You can derive the public key from your seed phrase whenever needed.
solana-keygen pubkey ASKThe CLI will prompt you to enter your seed phrase and passphrase, then display the corresponding public key.
Verifying a Keypair
You can verify that a seed phrase corresponds to a specific public key.
solana-keygen verify <PUBLIC_KEY> ASKHardware Wallets
For maximum security, Hardware Wallets store your private keys on a dedicated physical device, keeping them isolated from internet-connected computers. They are considered the gold standard for securing significant cryptocurrency holdings. While specific CLI commands for hardware integration can vary by device, they generally involve connecting the device and using commands that delegate signing authority to it.
👉 Explore secure wallet management strategies
Performing Basic Operations on the Solana Network
This section uses the Solana Devnet for examples, a test network where you can obtain free test SOL tokens (airdrop) to practice transactions without financial risk.
Requesting an Airdrop
An airdrop provides you with test SOL tokens on the Devnet. You can request up to 10 SOL per transaction.
General Syntax:
solana airdrop <AMOUNT> --url https://api.devnet.solana.comFor a File System Wallet:
Specify the keypair file path using the -k flag.
solana airdrop 10 -k ~/my-solana-fs-wallet-keypair.json --url https://api.devnet.solana.comFor a Paper Wallet:
Specify the wallet's public key directly.
solana airdrop 10 <PUBLIC_KEY> --url https://api.devnet.solana.comUpon success, the command returns a transaction signature and confirms the new balance.
Checking Account Balance
You can check the balance of any wallet for which you know the public key.
General Syntax:
solana balance <PUBLIC_KEY> --url https://api.devnet.solana.comFor a File System Wallet:
You can also use the keypair file to check its balance.
solana balance -k ~/my-solana-fs-wallet-keypair.json --url https://api.devnet.solana.comTransferring SOL Between Wallets
The transfer command allows you to send SOL from one wallet to another. A small transaction fee is deducted from the fee payer's account.
General Syntax:
solana transfer <RECIPIENT_PUBLIC_KEY> <AMOUNT> --url https://api.devnet.solana.com --fee-payer <FEEPAYER_KEYPAIR_OR_PATH>Example: Transfer from FS Wallet to Paper Wallet
This command sends 5 SOL from a File System Wallet to a Paper Wallet address, with the FS wallet also paying the transaction fee.
solana transfer --from ~/my-solana-fs-wallet-keypair.json <RECIPIENT_PUBLIC_KEY> 5 --url https://api.devnet.solana.com --fee-payer ~/my-solana-fs-wallet-keypair.jsonAfter the transfer, you can use the balance command to verify the updated balances in both wallets, noting that the sender's balance will be slightly less than the original amount minus the sent sum due to the transaction fee.
Frequently Asked Questions
What is the main difference between a File System Wallet and a Paper Wallet?
A File System Wallet stores the private key in a plain text file on your computer, making it convenient for frequent use but vulnerable if the file is compromised. A Paper Wallet involves generating and physically writing down the seed phrase, with no digital file created, offering superior security against online threats but requiring careful physical storage.
How can I ensure my Paper Wallet seed phrase is secure?
Write the seed phrase clearly on durable material like metal or heavy paper. Store it in a secure, private location such as a safe or safety deposit box. Never digitize it by taking a photo, storing it in a cloud document, or typing it into an unsecured device.
Why did my balance decrease by slightly more than the amount I sent?
Every transaction on the Solana network requires a small fee to be processed. This fee is paid by the account specified as the --fee-payer. The slight difference in your balance after a transfer accounts for the amount sent plus this nominal transaction fee.
Can I use the same CLI commands on the Mainnet?
Yes, the commands are identical. However, you must replace the --url parameter with the Mainnet RPC endpoint (https://api.mainnet-beta.solana.com) and remember that transactions on Mainnet involve real SOL tokens with real monetary value.
What should I do if I lose access to my File System Wallet keypair file?
If you have securely saved your seed phrase, you can fully recover your wallet and funds using the solana-keygen recover command. This underscores the critical importance of backing up your seed phrase during the initial wallet creation process.
Is it possible to use a hardware wallet with the Solana CLI?
Yes, the Solana CLI supports integration with popular hardware wallets. The process typically involves using specific commands that recognize the connected device and delegate the signing of transactions to it, keeping the private key secure on the hardware device at all times.