Created
August 21, 2015 19:48
-
-
Save linagee/1e44d53448d90bca5b57 to your computer and use it in GitHub Desktop.
Contract finder
This file contains hidden or 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
//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