7

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?

1 Answers1

0

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.
  • 1
    This will not work for contracts that were deployed by another contract. – Ismael Sep 27 '18 at 14:57
  • can you please explain in detail?I think "to" = 0x0 in the deployment txn, irrespective of whether external account or contract initiated the txn – ActionCures Sep 28 '18 at 17:05
  • 1
    A contract A can deploy a 'child' contract B with B child = new B(params); (in solidity). The child contract was created by an 'internal' transaction and it has no corresponding normal transaction with null 'to'. – Ismael Sep 28 '18 at 17:29