Hi all,
Running into an issue when trying to deploy an ERC-1155 token through a Factory contract. The logic of my contracts is as below.
I call this function below through my factory which in effect calls the ERC-1155 token constructor code below it.
function deployERC1155(address initialOwner, string memory _contractName, string memory _uri, string[] memory _names, uint[] memory _ids) public returns (address) {
ERC1155Token t = new ERC1155Token(initialOwner, _contractName, _uri, _names, _ids);
return address(t);
}
While the ERC-1155 constructor code looks like this:
constructor(address initialOwner, string memory _contractName, string memory _uri, string[] memory _names, uint[] memory _ids) Ownable(initialOwner) ERC1155(_uri) {
setURI(_uri);
}
Now, i've taken unrelated logic from both functions and only kept what's vital for explanation. I've found out that the setURI(_uri) function fails because it does not have the correct owner.
Now, I can get the code to work if i adjust the Ownable(initialOwner) to Ownable(msg.sender) but without it, when i try to set initialOwner during my function call to deployERC1155 it reverts.
From OP docs, I can see that im setting the access control correctly (link) via
constructor(address initialOwner) Ownable(initialOwner)
But i am unsure why it is not setting the address I set as the owner, as the setURI function fails.
Any insight is appreciated.