0
address[] child;

function createChildContract() onlyOwner public{
    address newChild = new Child(msg.sender);
    child.push(newChild);
    emit ChildCreated(newChild);
}

contract Child {
   address public owner;

constructor(address _owner) public{
    owner = _owner;
}

function getOwner() external view returns(address){
    return owner;
}

I can make child contracts with this code in testnet but in mainnet it dosen't work.

Does mainnet just impossible to create child contract? or my code is wrong?

  • You didn't paste all the code. – Peter Prographo Feb 11 at 10:01
  • What is the error you get in mainnet? – Lauri Peltonen Feb 11 at 10:08
  • There is no errors etherscan.io/address/0x486f7112a03e622af4619732a20b07b12a003159 transaction is success but there is no event and child variable is empty @LauriPeltonen – Drin Feb 11 at 10:11
  • @PeterPrographo Sorry im new here i don't know how to paste code – Drin Feb 11 at 10:15
  • None of your mainnet transaction contain any data (except contract creation). You are calling the contract wrong. – Lauri Peltonen Feb 11 at 10:20
0

Your transactions to the contract show that you aren't including any tx data, meaning you aren't calling createChildContract.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.