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.
- Python 3.6+
-
Clone the repository and navigate to the project directory.
-
Create a
.env
file with the following content:RPC_URL=https://api.mainnet-beta.solana.com TOKEN_CONTRACT=B6h248NJkAcBAkaCnji889a26tCiGXGN8cxhEJ4dX391
Replace the
RPC_URL
andTOKEN_CONTRACT
values with your own. For tracking the native SOL balance, setTOKEN_CONTRACT
to0x0
. -
Create a
solana_wallet.json
file 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
-
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.json
file:make example
-
To display help information:
make help
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.
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.
The script will save the wallet balances to an Excel file named solana_<TOKEN_CONTRACT>.xlsx
.