-
-
Save Fitblip/2433491f0433eb1e621d07431a4ae438 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import csv | |
from io import StringIO | |
from collections import defaultdict | |
airdrop_data = requests.get('https://raw.githubusercontent.com/Hover-Labs/kdao-airdrop/main/airdrop-data.csv') | |
cleaned_data = [x.strip().rstrip(',').replace(', ', ',') for x in airdrop_data.content.decode().split('\n') if x] | |
data_strio = StringIO('\n'.join(cleaned_data)) | |
addresses = {} | |
mermaid_data = defaultdict() | |
for airdrop_recipient in csv.DictReader(data_strio): | |
addresses[airdrop_recipient['address']] = airdrop_recipient['token allocation'] | |
f = open('/tmp/funding-source-analysis.txt', 'w') | |
for index, (address, _amt) in enumerate(addresses.items()): | |
chain = [address + "(*)"] | |
search_address = address | |
while True: | |
recv_funds = requests.get('https://api.tzkt.io/v1/accounts/{}/operations?type=activation,origination,transaction,reveal,migration¶meter.null&status=applied&limit=10&sort=0'.format(search_address)).json() | |
seed_tx = recv_funds[0] | |
if seed_tx['type'] == 'activation': | |
chain.append('ICO Activation') | |
break | |
if seed_tx['type'] == 'migration': | |
chain.append('ICO Activation/Migration') | |
break | |
sender_address = seed_tx['sender']['address'] | |
sender_alias = seed_tx['sender'].get('alias') | |
if sender_alias is None: | |
if sender_address in addresses: | |
chain.append(sender_address + "(*)") | |
else: | |
chain.append(sender_address) | |
search_address = sender_address | |
else: | |
chain.append(sender_alias) | |
break | |
chain_data = " -> ".join(chain[::-1]) | |
print(chain_data) | |
f.write(chain_data + "\n") | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment