[Ethereum] How to find deployed transaction hash of any given contract in chain, with just “contract address” information

contract-deployment

Am trying to write small application which will be able to find Contract deployment transaction with only input parameter – contract address. The application should be able to search entire net.,i,e say Rinkeby and should exactly find deployed transaction hash. This is applicable for any given contract address in rinkeby. I do not want to search with events or logs. Specifically am looking for how to find all the transactions with "0x0" as target programmatically?

Best Answer

I found the answer myself- Its pretty simple infact:

  1. Search for all the transaction from 0 to LatestBlock
  2. Get transactions in each block and loop through transactions one by one.
  3. Get Transaction receipt in each transaction and check whether its deployment transaction ['to' = '0x0'] and if so, get contract address.
  4. If given contract address matched input address, hurray we found the deployed transaction.
Related Topic