Last active
July 11, 2016 12:31
-
-
Save ckeenan/fa1a77823dba5b193c7cfeaa00acb756 to your computer and use it in GitHub Desktop.
Find DAO burn transactions
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
var Web3 = require('web3'); | |
var net = require('net'); | |
var fs = require('fs'); | |
var async = require('async'); | |
var client = net.Socket(); | |
var web3 = new Web3(new Web3.providers.IpcProvider("/root/.ethereum/geth.ipc", client)); | |
var daoAddr = '0xbb9bc244d798123fde783fcc1c72d3bb8c189413'; | |
var knownAttackers = {"0x969837498944ae1dc0dcac2d0c65634c88729b2d": true, "0xf35e2cc8e6523d683ed44870f5b7cc785051a77d": true, "0xe500732effa4922a97671cd310c613ba88c32315": true, "0x | |
a70d9810eda6e14810593270a8d57e3965bf890e": true, "0xfc4746b3f38f029737608315d63d17f7e867ed35": true, "0xac80cba14c08f8a1242ebd0fd45881cfee54b0a2": true, "0x15def77337168d707e47e68ab | |
9f7f6c17126b562": true, "0x13c7c27ea7ee89ec6607965b6f357b0109bc98b4": true, "0x5b7c73a41cd3a40364861e215a4dd7b2b7dfe196": true, "0x1dba1131000664b884a1ba238464159892252d3a": true}; | |
var currentBlock = firstBlock = 1600460; // block of first proposal | |
//var currentBlock = firstBlock = 1641000; // skip ahead to first Transfer event | |
var lastBlock = 1865388; //** update this | |
var transactions = [] | |
var transferEventSig = web3.sha3('Transfer(address,address,uint256)'); | |
async.whilst( | |
function() { return currentBlock < lastBlock; }, | |
function(callback) { | |
if (currentBlock % 1000 == 0) { | |
console.log(currentBlock); | |
fs.writeFileSync('relevantTransactions.json', JSON.stringify(transactions)); | |
} | |
web3.eth.getBlock(currentBlock++, function(err, block) { | |
async.each(block.transactions, function(tx, cb) { | |
web3.eth.getTransactionReceipt(tx, function(err, txr) { | |
txr.burns = txr.logs.filter(function(l) { return l.address === daoAddr && l.topics[0] === transferEventSig && web3.toBigNumber(l.topics[2]).e | |
q(0)}).length; | |
txr.transfers = txr.logs.filter(function(l) { return l.address === daoAddr && l.topics[0] === transferEventSig}).length; | |
if (txr.burns) transactions.push(txr); | |
cb(err); | |
}); | |
}, function(err) { | |
callback(err); | |
}); | |
}); | |
}, | |
function(err, n) { | |
console.log('transactions count', transactions.length); | |
fs.writeFileSync('relevantTransactions.json', JSON.stringify(transactions)); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment