This repository collects different scripts to perform queries against the Ethereum ETL tables using Google Big Query and perform simple processing to the results.
The results/
folder contains the outputs, the scripts and the
queries are as simple and short as possible to encourage third party
audits.
To test all the scripts you are required to export the
GOOGLE_APPLICATION_CREDENTIALS
environment variable.
Before all, install the requirements with pip install -r
requirements.txt
.
Since one cannot simply query all the existing Ethereum addresses checking for their balance the only way to find out the holdings of a specific token is retrace over the entire transactions history.
This can achived with this simple algorithm:
for row in client.query(query):
src, dst, val = row['from_address'], row['to_address'], int(row['value'])
if not src in holders: holders[src] = 0
if not dst in holders: holders[dst] = 0
if dst != zero_address: holders[dst] += val
if src != zero_address: holders[src] -= val
It’s important to emphatize how the correctness of these results is only a “condicio sine qua non” and it doesn’t grant a perfect implementation. However we consider this a sufficient degree of reliability.
To run it:
python verify_current_buidl_holders.py
Note that sometimes errors may occurs because there has been a recent transfer that is not available in the ETL table. You can manually check the latest transactions to be sure that this is the case.
This script gets the holders of the following tokens:
- buidl
- unifi
- arte
- usd
at the date “2020-01-31 04:20:00 UTC” and create a json containing all their addresses and a fixed amount of 99 GIL. Then this output will be used by the distributor contract to airdrop that amount of GIL, upon claim.
To run it:
python get_holders_for_airdrop.py
This produces an airdrop.json
file in the results/
folder.
A precomputed output is already present in this repository.