Disclosure: SolanaInfo is operated by the same team behind SolRecover.io, a paid recovery tool charging 1.9%. This guide explains how to perform the same operation for free using the Solana CLI.
Every SOL recovery tool — including ours — uses the same underlying Solana instruction to close token accounts. The difference is the interface and the fee. This guide strips away the interface and shows you how to execute the instruction directly, for free.
Technical Background
When a token account is closed, the SPL Token program executes the CloseAccount instruction. This instruction:
- Verifies the account has a zero token balance
- Transfers the account’s lamport balance (the rent deposit) to a designated recipient
- Sets the account’s data to zero
- Marks the account for deletion by the runtime
The rent deposit for a standard token account is 0.00203928 SOL (2,039,280 lamports). This is the minimum balance required to make the account rent-exempt, calculated as:
rent_exempt_minimum = (128 bytes account data + 165 bytes overhead) × rent_rate
When you use a paid tool, the transaction includes both the CloseAccount instruction and an additional transfer instruction that sends a percentage to the tool’s fee wallet. When you use the CLI, the transaction contains only the CloseAccount instruction — your full rent deposit goes directly back to your wallet.
Prerequisites
| Requirement | Details |
|---|---|
| Operating System | Windows, macOS, or Linux |
| Solana CLI | v1.18+ (installation below) |
| Wallet access | Keypair file, hardware wallet, or seed phrase |
| SOL balance | ~0.001 SOL for transaction fees |
| Time | 5-10 minutes |
Installation
macOS / Linux
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
Add to your shell profile for persistence:
echo 'export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
(Use ~/.zshrc on macOS if using zsh.)
Windows
Via PowerShell:
cmd /c "curl -sSfL https://release.anza.xyz/stable/install | sh"
Or use WSL for a full Linux environment.
Verify
solana --version
spl-token --version
Both commands should return version numbers. If spl-token is not found, install it separately:
cargo install spl-token-cli
Step 1: Configure RPC Endpoint
By default, the CLI uses the public Solana mainnet RPC. For better reliability (especially with many accounts), configure a dedicated endpoint:
# Use mainnet (default)
solana config set --url https://api.mainnet-beta.solana.com
# Or use a dedicated RPC provider for better rate limits
solana config set --url https://your-rpc-provider-url
Verify your configuration:
solana config get
Step 2: Enumerate Empty Accounts
SPL Token Program accounts
spl-token accounts --owner YOUR_WALLET_ADDRESS
Token-2022 Program accounts
spl-token accounts --owner YOUR_WALLET_ADDRESS --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
Understanding the output
Token Balance Account
---------------------------------------------------------------------------
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v 0 4kG...abc ← EMPTY (recoverable)
So11111111111111111111111111111111111111112 0.5 7xQ...def ← HAS BALANCE (skip)
DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263 0 9mR...ghi ← EMPTY (recoverable)
Each empty account holds approximately 0.00203928 SOL in rent. Count your zero-balance accounts and multiply to estimate your total recovery.
Step 3: Configure Wallet for Signing
File-system keypair
solana config set --keypair /path/to/your-keypair.json
Ledger hardware wallet
solana config set --keypair usb://ledger
The Ledger will prompt you to confirm each transaction on the device — the most secure option.
Recovering a keypair from a seed phrase
solana-keygen recover -o recovered-wallet.json
Enter your seed phrase when prompted. The keypair file is saved locally.
Security: Keep keypair files secure and delete them when no longer needed. Never share them or commit them to version control.
Step 4: Close Empty Accounts
Close all SPL Token empty accounts
spl-token close --owner YOUR_WALLET_ADDRESS --all
Close all Token-2022 empty accounts
spl-token close --owner YOUR_WALLET_ADDRESS --all --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
Close a specific account
spl-token close ACCOUNT_ADDRESS
What the output looks like
Closing account 4kG...abc, recovering 0.00203928 SOL
Signature: 3xMn...
Closing account 9mR...ghi, recovering 0.00203928 SOL
Signature: 5pNr...
Recovered 0.00407856 SOL from 2 accounts.
Safety guarantees
- The CLI will not close accounts with non-zero token balances
- If a close instruction fails, remaining accounts are unaffected
- Each closure is an independent transaction — partial failures do not roll back successful closures
- The rent deposit goes directly to your wallet (the account owner)
Step 5: Verify Recovery
Check balance
solana balance YOUR_WALLET_ADDRESS
Check transaction history
solana transaction-history YOUR_WALLET_ADDRESS --limit 20
Verify on block explorer
Visit Solana Explorer and paste your wallet address. Recent transactions should show “Close Account” entries, each returning ~0.002 SOL.
Confirm accounts are gone
Re-run the listing command:
spl-token accounts --owner YOUR_WALLET_ADDRESS
Previously empty accounts should no longer appear.
Cost Analysis: CLI vs Paid Tools
| Recovery Amount | CLI Cost | 1.9% Tool | 5% Tool | 15% Tool | 20% Tool |
|---|---|---|---|---|---|
| 0.02 SOL (10 accounts) | ~$0.0001 | $0.05 | $0.14 | $0.42 | $0.56 |
| 0.10 SOL (50 accounts) | ~$0.0004 | $0.27 | $0.70 | $2.10 | $2.80 |
| 0.20 SOL (100 accounts) | ~$0.0007 | $0.53 | $1.40 | $4.20 | $5.60 |
| 1.02 SOL (500 accounts) | ~$0.0035 | $2.71 | $7.14 | $21.42 | $28.56 |
| 2.04 SOL (1000 accounts) | ~$0.007 | $5.43 | $14.28 | $42.84 | $57.12 |
CLI cost = Solana network fees only (~0.000005 SOL per transaction). USD values at $140/SOL.
The percentage-based pricing model of paid tools means the more SOL you recover, the more you pay. The CLI cost is effectively flat regardless of recovery amount.
Alternative Free Methods
Phantom Wallet
Phantom includes a built-in feature to close empty accounts:
Settings → Close Empty Accounts → Review → Confirm
This is the easiest free option for non-technical users. No CLI installation required.
Solflare Wallet
Solflare offers similar functionality through its account management settings.
Solana Explorer
Some block explorer interfaces allow closing accounts directly by connecting your wallet. Visit explorer.solana.com, navigate to your wallet’s token accounts, and look for close options.
Troubleshooting Reference
| Issue | Cause | Solution |
|---|---|---|
command not found |
CLI not in PATH | Restart terminal or add to PATH manually |
insufficient funds |
Not enough SOL for tx fees | Deposit ~0.001 SOL to cover network fees |
account has non-zero balance |
Account still holds tokens | Transfer tokens first, then close |
RPC rate limit exceeded |
Too many requests to public RPC | Use a dedicated RPC provider or add delays |
blockhash expired |
Transaction took too long | Retry — network was congested |
custom program error |
Token-2022 account with close authority | Check if the token has a close authority set; may need additional flags |
Why We Published This
We operate SolRecover.io at 1.9%, the lowest fee among paid recovery tools. Our business model depends on people paying for convenience.
We published this guide anyway because:
-
Informed users make better decisions. If you know the free option exists and still choose a paid tool for convenience, that is a legitimate choice. If you do not know the free option exists, you cannot make an informed decision.
-
Extortionate fees are bad for the ecosystem. Tools charging 15-20% for a simple CloseAccount instruction are taking advantage of users who do not know they have alternatives. By publishing this guide, we hope to push the entire market toward fairer pricing.
-
Transparency builds trust. We would rather earn your trust by being honest about alternatives than trick you into thinking paid tools are the only option.
The recovery tool market should compete on convenience, reliability, and user experience — not on information asymmetry.
For more technical details on how token accounts work, see our guide on Solana account rent. For a detailed comparison of paid tools, read our fee comparison.