I have a clonable contract which I'm passing to the clone factory contract and I'm trying to access the functions inside it but for some reason only the view functions work.
this.nft = await NFT.new(this.user.address,"Dudu","DUD","https://dudublog.com/images/",{from:creator});
this.nftFactory = await NFTFactory.new(this.nft.address,{from:creator});
Passing the clonable contract address to the factory creates the clones, however when I call the mint function from the clone contract, it gives me a revert error. The function was tested on the initial contract with a constructor instead of the initialize() function. This is my code so far:
it("should mint from clone contract",async function(){
await this.nftFactory.createNFTContract("0x1","Gaga","TCP","https://gaga.io/");
const contractAddressess = await this.nftFactory.getNFTAddressess();
const nftC1 = await NFT.at(contractAddressess[0]);
await nftC1.mintToken("https://gaga.io/","12312",{from:creator});//doesn't work
let tokensForOwner = await nftC1.getTokensForAddress(creator);//works
console.log(tokensForOwner.toString());
})
As far as I saw from the examples, it should work and strangely the view functions work which makes me believe that I'm either missing something or my approach is wrong. Does someone know how can I achieve this?
Best Answer
I found the answer to my problem. The clone factory was missing the transferOwnership of the token contract which prevented the caller to call the functions of the clonable contract.