solana-balance-cli
v1.1.0
Published
CLI tool to check Solana wallet balance in SOL and USD
Maintainers
Readme
Solana Balance CLI
A simple command-line tool to check your Solana wallet balance in both SOL and USD.
Package: solana-balance-cli | Command: sol-balance
Features
- ✅ Fetch real-time Solana wallet balance
- ✅ Display balance in SOL
- ✅ Convert balance to USD using live price data from CoinGecko
- ✅ Clean, formatted output
- ✅ Error handling for invalid addresses
Installation
Install from npm (Recommended)
npm install -g solana-balance-cliInstall locally
npm install solana-balance-cliDevelopment Installation
git clone <repository-url>
cd solana-balance-cli
npm install
npm run buildUsage
Global Installation
After installing globally, you can use the sol-balance command from anywhere:
sol-balance <WALLET_ADDRESS>Local Installation
If installed locally, use it with npx:
npx sol-balance <WALLET_ADDRESS>Or add it to your package.json scripts:
{
"scripts": {
"check-balance": "sol-balance"
}
}Example
sol-balance CuieVDEDtLo7FypA9SbLM9saXFdb1dsshEkyErMqkRQqOutput
🔍 Fetching wallet balance...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📍 Wallet: CuieVDEDtLo7FypA9SbLM9saXFdb1dsshEkyErMqkRQq
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💰 Balance: 0.0057 SOL
💵 SOL Price: $123.23 USD
💸 USD Value: $0.71 USD
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Global Installation (Optional)
To use the tool globally as sol-balance:
npm linkThen you can run:
sol-balance <WALLET_ADDRESS>Technologies Used
- TypeScript - Type-safe development
- @solana/web3.js - Solana blockchain interaction
- axios - HTTP requests for price data
- commander - CLI framework
- CoinGecko API - Real-time SOL/USD price data
Project Structure
solana-balance-cli/
├── src/
│ ├── index.ts # Main CLI entry point
│ ├── solana.ts # Solana balance fetching logic
│ └── price.ts # USD price fetching logic
├── dist/ # Compiled JavaScript output
├── package.json
├── tsconfig.json
└── README.mdError Handling
The tool handles various error scenarios:
- Invalid wallet addresses
- Network connection issues
- API failures
Development
Version Management
This project uses Changesets for version management and changelog generation.
Creating a Changeset
When you make changes that should be released:
npm run changesetThis will prompt you to:
- Select the type of change (major, minor, patch)
- Write a summary of the changes
This creates a changeset file in .changeset/ that describes your changes.
After creating a changeset, commit and push it:
git add .changeset/
git commit -m "chore: add changeset"
git pushVersioning and Publishing
To create a new version and update the changelog:
npm run versionThis will:
- Read all changesets
- Update the version in
package.json - Generate/update
CHANGELOG.md - Remove used changeset files
After versioning, commit the changes:
git add .
git commit -m "chore: version bump"
git pushTo publish to npm:
npm run releaseThis will:
- Build the project
- Publish to npm using changesets
Or you can publish manually after versioning:
npm run version
git add .
git commit -m "chore: version bump"
git push
npm publishLicense
ISC
