I have a smart contract with a function named, let's say, deployNewContract(..) this function takes some arguments and deployed a new contract based on the parameters. I am able to call the function from Ethereum-Wallet and deploy the contract. Everything works smooth.

Now, I have a public array of address type in which I store address of the newly deployed contract so I can get the address of the contract from that array.

Now the problem arises when I try to deploy the contract using web3 or geth console. I execute the function of my contract and get the transaction hash and mine it obviously.

But how do I get the address of newly deployed contract?

Unfortunately, my pubic array shows no new entry this time and when I check eth.getTransactionReciept, I get null in contract address.

Here is output of eth.getTRansactionReceipt(txHash); :

  blockHash: "0xbde761102ec08bef4ba55a703261da071ba0e99b5ef6c8d7e77bf5c1a6e27ba1",
  blockNumber: 413,
  contractAddress: null,
  cumulativeGasUsed: 313570,
  from: "0x5cb1ffd42dea0afeefb8950adcb2b6e5cff2efc3",
  gasUsed: 313570,
  logs: [{
      address: "0x9d160c47ae9ccf33078c9513492e5499cee53439",
      blockHash: "0xbde761102ec08bef4ba55a703261da071ba0e99b5ef6c8d7e77bf5c1a6e27ba1",
      blockNumber: 413,
      data: "0x000000000000000000000000d573b1767915530a05a0250f5f4fc985427a6d534e65772050617469656e74205265676973746572656400000000000000000000",
      logIndex: 0,
      removed: false,
      topics: ["0xd5a6c4477254cab9dfc267110730e333e3c94ea3a93795b56c93b0c8757488ce"],
      transactionHash: "0x1b6e8970275eda4b39690cb868bd305983d483dee38a042a1bcfc3dbfada22d2",
      transactionIndex: 0
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  root: "0x87d205881fc430586b344d0dda84cf72ba99c6bd198171f6e42c008fcad7c993",
  to: "0x9d160c47ae9ccf33078c9513492e5499cee53439",
  transactionHash: "0x1b6e8970275eda4b39690cb868bd305983d483dee38a042a1bcfc3dbfada22d2",
  transactionIndex: 0


  • I am on private test network
  • I think it's more of what to do? So I am not posting my code (to avoid question from being lengthy). If you feel that code is needed, I will update the question.
  • 1
    Did you try triggering an event from that function to see if the contract is getting deployed by logging deployed contract's address? – Sanchit Jul 13 '17 at 1:13
  • How do you deploy a new contract? As Sanchit says you usually generate an event when you have to notify something. – Ismael Jul 13 '17 at 4:52
  • I hadn't fired events. I should, my bad. Will post the results after adding events so that I can be sure that my contract gets deployed. – Prashant Prabhakar Singh Jul 13 '17 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.