π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
USEFUL LINKS
Last updated