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.
Can't do that directly. There are several workarounds, though, depending on your use case.
You can call the
ERC721fromFactory, passing the user address as a parameter. Either to a custom function (if you can modify theERC721code) 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
ERC721approving yourFactorycontract to operate their tokens. And second they send a transaction to yourFactorycontract that makes the subsequent call toERC721transferring their tokens.The user can also make a transaction directly to the
ERC721contract, for example executing thetransferFrom()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
ERC721contract directly) - unless you can modify theERC721source code and implement a custom function that bypasses the approval requirement.