A command-line tool to retrieve all SPL token addresses associated with a Solana wallet address using the getTokenAccountsByOwner RPC endpoint.
- π Quick Discovery: Find all SPL tokens held by any Solana wallet
- π¨ Multiple Output Formats: List, JSON, CSV, Table, and Simple formats
- π File Export: Save results to a file
- π Custom RPC Support: Use your own RPC endpoint
- β‘ Fast & Efficient: Optimized for performance with proper error handling
- π― Address Validation: Validates Solana addresses before querying
- π Interactive Mode: Simple scripts that prompt for wallet address and output clean results
- π― Clean Output: Simple format outputs only token addresses with no extra messages
- π Scriptable: Perfect for automation and piping to other commands
npm install -g spl-token-finder# Clone the repository
git clone https://github.com/Danservfinn/spltokenaddress.git
cd spltokenaddress
# Install dependencies
npm install
# Build the project
npm run build
# Link globally (optional)
npm linkThe easiest way to use the tool - just run and enter a wallet address when prompted:
# Option 1: Shell script (macOS/Linux)
./run.sh
# Option 2: Node.js script (Cross-platform)
node run.js
# Option 3: NPM script
npm run run-interactiveExample session:
$ ./run.sh
Enter Solana wallet address: A7Kj5g44rEtXHNbdRRSMZ9eDk6Z66XGzjxvZDt1zTWdD
ETYoL6Ru47ZSHZa7JpocMUJiPxPdgV3yzATDG2TMvTTC
FMwXnEU3KkX2tLRJ9Mk1UZ4AveZuum3PTRpkv3SFapZf
n54ZwXEcLnc3o7zK48nhrLV4KTU5wWD4iq7Gvdt5tik
kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6
AMjzRn1TBQwQfNAjHFeBb7uGbbqbJB7FzXAnGgdFPk6K
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v# Simple format - just token addresses (cleanest)
npm run dev -- <wallet_address> --format simple
# After building (npm run build)
node dist/cli.js <wallet_address> --format simple# Default list format with balances
npm run dev -- <wallet_address>
# JSON format
npm run dev -- <wallet_address> --format json
# CSV format
npm run dev -- <wallet_address> --format csv
# Table format
npm run dev -- <wallet_address> --format table
# Simple format (just addresses)
npm run dev -- <wallet_address> --format simple-
Simple output (just token addresses)
npm run dev -- A7Kj5g44rEtXHNbdRRSMZ9eDk6Z66XGzjxvZDt1zTWdD --format simple
-
Save to file
npm run dev -- A7Kj5g44rEtXHNbdRRSMZ9eDk6Z66XGzjxvZDt1zTWdD --format simple --output tokens.txt
-
JSON output
npm run dev -- A7Kj5g44rEtXHNbdRRSMZ9eDk6Z66XGzjxvZDt1zTWdD --format json
-
Table format
npm run dev -- A7Kj5g44rEtXHNbdRRSMZ9eDk6Z66XGzjxvZDt1zTWdD --format table
-
Custom RPC endpoint
npm run dev -- A7Kj5g44rEtXHNbdRRSMZ9eDk6Z66XGzjxvZDt1zTWdD --rpc https://your-rpc-endpoint.com --format simple
-
Pipe to other commands
# Count tokens ./run.sh | wc -l # Save to file ./run.sh > my_tokens.txt # Search for specific token ./run.sh | grep "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
| Option | Short | Description | Default |
|---|---|---|---|
--format <format> |
-f |
Output format: list, json, csv, table, simple |
list |
--output <file> |
-o |
Save output to file | Console output |
--rpc <url> |
-r |
Custom RPC endpoint URL | Solana mainnet |
--timeout <seconds> |
-t |
Request timeout in seconds | 30 |
--help |
-h |
Display help information | - |
--version |
-V |
Display version number | - |
simple- Clean output with just token mint addresses (one per line) - Perfect for scriptinglist- User-friendly list with balances and colors (default)table- Formatted table with columns for easy readingjson- Structured JSON data for programmatic usecsv- Comma-separated values for spreadsheet import
Wallet: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
Found 3 SPL tokens:
1. EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v (Balance: 100.5)
2. So11111111111111111111111111111111111111112 (Balance: 1.5)
3. 7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT (Balance: 0)
{
"walletAddress": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
"tokenCount": 3,
"tokens": [
{
"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"tokenAccount": "FqWh4BPpGKvWS7xYLunV4Pr7g7NvJTJGCG2MBJdgKJvP",
"balance": 100.5,
"decimals": 6,
"rawAmount": "100500000"
}
]
}Wallet: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
Found 3 SPL tokens:
βββββ¬βββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββ¬βββββββββββ
β # β Mint Address β Balance β Decimals β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββΌβββββββββββ€
β 1 β EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1vβ 100.5 β 6 β
β 2 β So11111111111111111111111111111111111111112 β 1.5 β 9 β
β 3 β 7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFTβ 0 β 6 β
βββββ΄βββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββ΄βββββββββββ
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
So11111111111111111111111111111111111111112
7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT
# Install dependencies
npm install
# Build the project (optional - for production use)
npm run build# Run in development mode
npm run dev -- <wallet_address> --format simple
# Run tests
npm test
# Lint code
npm run lint
# Build for production
npm run build# Run interactive mode (builds automatically)
npm run run-interactive
# Or run directly
./run.sh # Shell script (macOS/Linux)
node run.js # Node.js script (cross-platform)# Create a client-ready package
./client-package.sh
# This creates a dist-client/ folder and spl-token-finder-client.zip
# Perfect for sharing with clients who need the toolYou can also use the TokenFinder class directly in your TypeScript/JavaScript projects:
import { TokenFinder } from 'spl-token-finder/dist/services/tokenFinder';
import { validateAndGetPublicKey } from 'spl-token-finder/dist/utils/validation';
async function getTokens(walletAddress: string) {
const publicKey = validateAndGetPublicKey(walletAddress);
const tokenFinder = new TokenFinder('https://api.mainnet-beta.solana.com');
const tokenData = await tokenFinder.getTokenAccounts(publicKey);
return tokenData.tokens;
}See the examples/ directory for more detailed examples.
-
Clone and setup:
git clone https://github.com/Danservfinn/spltokenaddress.git cd spltokenaddress npm install -
Run the interactive script:
./run.sh # Enter wallet address when prompted -
Or use direct command:
npm run dev -- <wallet-address> --format simple
That's it! The app will validate the address, connect to Solana, fetch the tokens, and output just the token mint addresses.
The tool handles various error scenarios gracefully:
- Invalid Address: Validates Solana address format before making RPC calls
- RPC Connection Errors: Clear error messages for connection failures
- Rate Limiting: Detects and reports rate limit errors
- Timeout: Configurable timeout with clear error messages
- Empty Results: Friendly message when no tokens are found
- Uses
getParsedTokenAccountsByOwnerfor efficient data retrieval - Implements timeout to prevent hanging requests
- Sorts tokens by balance for better readability
- Minimal dependencies for fast execution
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see the LICENSE file for details
- Built with Solana Web3.js
- CLI powered by Commander.js
- Beautiful terminal output with Chalk
For issues, questions, or contributions, please visit the GitHub repository.