Skip to content

Automate SPL token airdrops on the Solana blockchain with this Python script. Configure for devnet or mainnet, manage recipients, log transactions, and prevent duplicates.

License

Notifications You must be signed in to change notification settings

leftkats/solana-spl-airdrop

Repository files navigation

☀️🐍📄 Solana SPL Token Airdrop Script

Solana Python PyYAML

codecov

Solana SPL Token Airdrop Script

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.

Description

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.

Features

  • 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-token CLI for token transfers.

Installation

  1. Clone the repository:

    git clone [repository URL]
    cd [repository directory]
  2. Install dependencies:

    Ensure you have Python 3.6+ installed.

    pip install pyyaml
  3. Install Solana CLI:

    Follow the official Solana CLI installation instructions: Solana CLI Installation

  4. Configure Solana CLI:

    Run solana config set --url <your_rpc_url> and solana config set --keypair <your_keypair_path> to configure your Solana CLI.

  5. Configure config.yml:

    Create a config.yml file 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.

  6. Create airdrop/recipients.txt:

    Create a airdrop/recipients.txt file with recipient addresses and amounts, one per line, separated by a comma:

    recipient_address_1,amount_1
    recipient_address_2,amount_2
    ...
    

Usage

  1. Run the script:

    python your_script_name.py

    The script will read the recipients.txt file and airdrop tokens to each recipient.

  2. 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)

Files

  • 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.

Wall of Contributors

If you like the repo please support with a ⭐

Thank you for being here!

About

Automate SPL token airdrops on the Solana blockchain with this Python script. Configure for devnet or mainnet, manage recipients, log transactions, and prevent duplicates.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages