🐍Airdrop Code

Code for generating a tap protocol airdrop from .csv

β˜† PYTHON CODE β˜†

import csv
import json

def generate_json_from_csv(csv_file_path, output_json_path):
    # List to store the addresses from the CSV
    addresses = []

    # Read the CSV and extract the addresses
    with open(csv_file_path, 'r') as csv_file:
        csv_reader = csv.reader(csv_file)
        next(csv_reader)  # Skip the header row
        for row in csv_reader:
            # Ensure the address is lowercase if it starts with bc1
            address = row[1].strip()
            if address.startswith("bc1"):
                address = address.lower()
            addresses.append(address)

    # Format the addresses into the JSON structure
    formatted_data = {
        "p": "tap",
        "op": "token-send",
        "items": []
    }

    for address in addresses:
        formatted_data["items"].append({
            "tick": "BUNNY",
            "amt": "10000",
            "address": address
        })

    # Save the formatted data to a JSON file
    with open(output_json_path, 'w') as json_file:
        json.dump(formatted_data, json_file, indent=4)

    print(f"JSON saved to {output_json_path}")

# Call the function to generate the JSON
generate_json_from_csv('drop.csv', 'output.json')

HOW TO MODIFY

β˜† Step 1. Change these values to your ticker and airdrop amount

β˜† Step 2. Change these values to match your .csv name and desired output

β˜† Step 3. Save the python code. Make sure the .csv file is in same directory and properly formatted with the wallet address on the second column. Afterwards run the python code from the terminal.

β˜† If all worked, it will generate a new file: output.json in the following format

circle-info

Make sure to TAP! After inscribing the token-send JSON, you will have to send the inscription to yourself in order to complete the Airdrop!


Instructional Video
circle-info

Follow @ordinalOSarrow-up-right for more information.

Last updated