Created
December 19, 2018 14:25
-
-
Save chlp/bf92df0c37868ebd7bdc7651c3462b14 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
<?php | |
$fileName = 'balances.csv'; | |
file_put_contents($fileName, "address;balance\r\n"); | |
$addresses_str = "0x1c1f7cf92e3fd0cc449ef08724a6c59c06a33c9c | |
0xaba2f30af702f3d250a54566bf840bdbcfd8b05c | |
0xf9f3bf7fdfd156fa73c18e3b1b9780981a8227dc | |
0xab5f64fbad42c114ba6d80bd3818d68d9b85ecb4 | |
0x2243211fd15243a273fa23a3271d0c28a40a1dbb | |
0x817984053851ec4b3c4e412be800a4868564b420"; | |
$addresses = explode("\n", $addresses_str); | |
$count = count($addresses); | |
foreach ($addresses as $i => $address) { | |
echo "Progress i: $i count: $count\r"; | |
$data = @json_decode(file_get_contents("https://api.etherscan.io/api?module=account&action=tokenbalance&contractaddress=0x88d50b466be55222019d71f9e8fae17f5f45fca1&address=$address&tag=latest"), true); | |
if ($data['status'] != 1) { | |
echo "\r\nERROR $address\r\n"; | |
} | |
$balance = bcdiv($data['result'], '100000000', 8); | |
file_put_contents($fileName, "$address;$balance\r\n", FILE_APPEND); | |
if ($i % 15) { | |
sleep(1); | |
} | |
} |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
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
address;balance | |
0x1c1f7cf92e3fd0cc449ef08724a6c59c06a33c9c;636476.00000000 | |
0xaba2f30af702f3d250a54566bf840bdbcfd8b05c;3000.00000000 | |
0xf9f3bf7fdfd156fa73c18e3b1b9780981a8227dc;30000.00000001 | |
0xab5f64fbad42c114ba6d80bd3818d68d9b85ecb4;170097.98256825 | |
0x2243211fd15243a273fa23a3271d0c28a40a1dbb;757658.49158100 | |
0x817984053851ec4b3c4e412be800a4868564b420;854.00000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment