This Python script automates the process of airdropping SPL tokens to a list of recipients on the Solana blockchain. It utilizes the spl-token CLI and logs transaction details.
The Airdrop class manages the distribution of SPL tokens. It reads recipient addresses and amounts from a recipients.txt file, sends the tokens using the spl-token CLI, and logs the results. It supports both devnet and mainnet configurations through a config.yml file. It also tracks already paid addresses to prevent duplicate transactions.
- Configuration: Supports devnet and mainnet configurations via
config.yml. - Recipient Management: Reads recipient addresses and amounts from
airdrop/recipients.txt. - Transaction Logging: Logs successful and failed transactions in separate JSON files.
- Paid Address Tracking: Prevents duplicate transactions by tracking already paid addresses in
airdrop/paid.ndjson. - Error Handling: Logs errors and provides detailed output for debugging.
- Solana CLI Integration: Utilizes the
spl-tokenCLI for token transfers.
-
Clone the repository:
git clone [repository URL] cd [repository directory] -
Install dependencies:
Ensure you have Python 3.6+ installed.
pip install pyyaml
-
Install Solana CLI:
Follow the official Solana CLI installation instructions: Solana CLI Installation
-
Configure Solana CLI:
Run
solana config set --url <your_rpc_url>andsolana config set --keypair <your_keypair_path>to configure your Solana CLI. -
Configure
config.yml:Create a
config.ymlfile in the root directory with the following structure:devnet: url: "[https://api.devnet.solana.com](https://api.devnet.solana.com)" keypair_path: "/path/to/your/devnet.json" token_address: "your_devnet_token_address" mainnet: url: "[https://api.mainnet-beta.solana.com](https://api.mainnet-beta.solana.com)" keypair_path: "/path/to/your/mainnet.json" token_address: "your_mainnet_token_address"
Replace placeholders with your actual values.
-
Create
airdrop/recipients.txt:Create a
airdrop/recipients.txtfile with recipient addresses and amounts, one per line, separated by a comma:recipient_address_1,amount_1 recipient_address_2,amount_2 ...
-
Run the script:
python your_script_name.py
The script will read the
recipients.txtfile and airdrop tokens to each recipient. -
Devnet or Mainnet: The script defaults to devnet. If you want to use mainnet, change the first line of the multisend() function to
airdrop = Airdrop(devnet=False)
config.yml: Configuration file for Solana network and keypair settings.airdrop/recipients.txt: List of recipient addresses and amounts.airdrop/paid.ndjson: Log of paid addresses and transaction signatures.airdrop/airdrop-<YYYY-MM-DD>-logs-succeed.json: Log of successful transactions.airdrop/airdrop-<YYYY-MM-DD>-logs-failed.json: Log of failed transactions.
If you like the repo please support with a ⭐
Thank you for being here!