0

I wanted to call the mint function which is in ERC721 Contract by factory contract. when i called, The factory contract address is taking as msg.sender.

And i also tried by delegate call. but am not able to update the state variables in ERC721.

Is there any possible way for this ???

I want to call the mint function which is in ERC721 contract by factory contract. and also the state variables should change in ERC721 contract.

1 Answers1

0

Can't do that directly. There are several workarounds, though, depending on your use case.

  1. You can call the ERC721 from Factory, passing the user address as a parameter. Either to a custom function (if you can modify the ERC721 code) or as a parameter of one of the existing functions.

    Passing the user address as a parameter is useful when you want to transfer user's tokens for example. First they send one transaction to ERC721 approving your Factory contract to operate their tokens. And second they send a transaction to your Factory contract that makes the subsequent call to ERC721 transferring their tokens.

  2. The user can also make a transaction directly to the ERC721 contract, for example executing the transferFrom() function transferring their tokens to you.

Because of how the ERC721 standard is designed, there's no way to transfer users' tokens directly without their prior approval (that needs to happen in a separate transaction to the ERC721 contract directly) - unless you can modify the ERC721 source code and implement a custom function that bypasses the approval requirement.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100