Search code examples
blockchainethereumsoliditysmartcontracts

How to extract all smart contracts on the Ethereum blockchain?


My goal is to find greedy, prodigal, and suicidal smart contracts on the Ethereum blockchain. Is there any trick that by using that I could extract all smart contracts on Ethereum blockchain?


Solution

    1. Get an Ethereum node

    2. Walk all mined Ethereum blocks from genesis block 1 - to latest you can e.g. use Web3.py or Web3.js to interact with your node API

    3. Check all transactions in a block - use web3.eth.getTransactionFromBlock

    4. If the transaction is a contract deployment transaction you have your smart contract