Hello,
I built a UUPS upgradeable contractFactory using the upgrades plugin, and when I try to test it or even deploy it locally, I get an error:
Error: VM Exception while processing transaction: reverted with reason string 'Initializable: contract is already initialized'
This is my deploy code:
const VFactory = await hre.ethers.getContractFactory("VFactory");
const vFactory = <VFactory>(
await upgrades.deployProxy(VFactory, [av.address, wl.address], { kind: 'uups' })
);
console.log("VFactory deployed to:", vFactory.address)
And this is the logic contract initialize function:
function initialize(address _template, address _whitelist) initializer public {
__ERC721_init("AW 2", "AW-V2");
super.initialize("AW 2");
__AccessControl_init();
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
require(_template != address(0), "VFactory: invalid template");
template = _template;
whitelist = _whitelist;
}
One thing to note is that I have used deployProxy within this same file on several other contracts and it worked seamlessly.
Any insights are highly appreciated!