Skip to content

Instantly share code, notes, and snippets.

@linagee
Created August 21, 2015 19:48
Show Gist options
  • Save linagee/1e44d53448d90bca5b57 to your computer and use it in GitHub Desktop.
Save linagee/1e44d53448d90bca5b57 to your computer and use it in GitHub Desktop.
Contract finder
//Look through the last 1000 blocks for contract addresses
var contractAddresses = [];
var blockNumber = eth.getBlock('latest').number;
console.log("Current block number: " + blockNumber);
for (var x = blockNumber; x > blockNumber - 1000; x--) {
var transactions = eth.getBlock(x).transactions;
var transactionsCount = transactions.length;
if (transactionsCount != 0) {
for (var y = 0; y < transactionsCount; y++) {
var transactionReceipt = eth.getTransactionReceipt(transactions[y]);
if (transactionReceipt.contractAddress !== null) {
console.log(transactionReceipt.contractAddress + " in TX: " + transactions[y] + " (block: " + x + ")");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment