This script fetches the balance of a specified Solana token for all addresses listed in a JSON file. It supports checking the native SOL balance as well as SPL token balances.
Solana Token Balance Checker
This script fetches the balance of a specified Solana token for all addresses listed in a JSON file. It supports checking the native SOL balance as well as SPL token balances.
Requirements
- Python 3.6+
Setup
- Clone the repository and navigate to the project directory.
- Create a
.envfile with the following content:
RPC_URL=https://api.mainnet-beta.solana.com
TOKEN_CONTRACT=B6h248NJkAcBAkaCnji889a26tCiGXGN8cxhEJ4dX391
Replace the RPCURL and TOKENCONTRACT values with your own. For tracking the native SOL balance, set TOKEN_CONTRACT to 0x0.
- Create a
solana_wallet.jsonfile with the following content:
[
{
"isConnected": true,
"address": "DHAzXyqVFqw31qX6Jhvm8o6QPBKy67dAYRjMiVMuG4tm",
"balance": null,
"isDisabled": false,
"type": "SOL",
"phrase": "-=--=-=-=-",
"label": null,
"ens": null,
"group": ["Personal Group"]
}
]
You can also generate a sample JSON file using the Makefile:
make example
Usage
- To install dependencies and run the script:
make all
- To install dependencies only:
make setup
- To run the script only:
make run
- To clean up generated Excel files:
make clean
- To create a sample
solana_wallet.jsonfile:
make example
- To display help information:
make help
Tracking Native SOL Token
To track the native SOL balance, set the TOKEN_CONTRACT variable in your .env file to 0x0:
RPC_URL=https://api.mainnet-beta.solana.com
TOKEN_CONTRACT=0x0
This will make the script query the native SOL balance for the given wallet addresses.
Tracking SPL Tokens
To track an SPL token balance, set the TOKEN_CONTRACT variable in your .env file to the mint address of the SPL token:
RPC_URL=https://api.mainnet-beta.solana.com
TOKEN_CONTRACT=B6h248NJkAcBAkaCnji889a26tCiGXGN8cxhEJ4dX391
Replace B6h248NJkAcBAkaCnji889a26tCiGXGN8cxhEJ4dX391 with the mint address of your desired SPL token.
Output
The script will save the wallet balances to an Excel file named solana<TOKENCONTRACT>.xlsx.
🔧 Useful Resources
| Tool Name | Description | Link | | ---------------------------- | -------------------------------------------- | ---------------------------------------------------------------- | | 🧬 Multi-Base64 Converter | Encode/decode Base64 strings | Open | | 🔍 RegEx Validator & Tester | Test and validate Regular Expressions | Open | | 🔐 JWT Encoder & Decoder | Decode and verify JSON Web Tokens | Open | | 🌐 User Agent Generator | Generate random browser user agents | Open | | ⏱️ Timestamp Converter | Convert timestamps to human-readable format | Open | | 🌎 World Time Zone Converter | Explore and convert between world time zones | Open | | ⚡ Speed Your Math | Improve mental math speed and accuracy | Open | | 🧠 Memory Trainer | Train and boost your short-term memory | Open | | 🔢 Sequence Challenges | Logic and number sequence training | Open |