Getting the address of a contract deployed by another contract

前端 未结 2 1703
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-06 03:06

I am trying to deploy a contract from another factory contract and then return the address of the newly created contract. The address it returns however is the transaction hash

2条回答
  •  清酒与你
    2021-02-06 03:47

    We ran across this problem today, and we're solving it as follows:

    In the creation of the new contract raise an event.

    Then once the block has been mined use the transaction hash and call web3.eth.getTransaction: http://web3js.readthedocs.io/en/1.0/web3-eth.html#gettransaction

    Then look at the logs object and you should find the event called by your newly created contract with its address.

    Note: this assumes you're able to update the Solidity code for the contract being created, or that it already calls such an event upon creation.

提交回复
热议问题