0

I have been trying to develop a parent contract that will deploy other contracts on request with different parameters. I came across the "new" keyword which seemed like a perfect choice.

But when I am trying to deploy the parent contract and deploy child contracts from it, the same parent is getting deployed again.

I am writing the contract on remix and using Ganache.

The code for the contract is as below:

pragma solidity ^0.5.1;

contract Factory {
    address[] public newContracts;

    function createContract (string memory name) public{
        address newContract = address(new MyContract(name));
        newContracts.push(newContract);
    } 
}

contract MyContract {
    string public Name;

    constructor (string memory name) public {
        Name = name;
    }
}
0

Are you sure!!, i tested it and it does not deploy the factory contract :/.

How are you deploying the child contract?

enter image description here

Your Answer

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

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