I have a function in my contract minter.sol
that creates another contract etnX.sol
:
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
}
I want to call this function in truffle and get new contract address. I'm trying to do so:
const minter = artifacts.require('../contracts/minter.sol')
const etnX = artifacts.require('etnX')
const etnXs = [100,200,500,1000,10000,100000,1000000,10000000]
module.exports = async function(deployer) {
deployer.deploy(minter).then(async() => {
var minterInstance = await minter.deployed();
for (var i=0; i<etnXs.length;i++)
await minterInstance.createNewContract("x","x", etnXs[i]);
var x = await etnX.deployed();
console.log(x.address);
})
};
However, it doesn't deploy. Can someone explain me how to do this?