Hello, I'm building an upgradeable ERC 1155 contract and I want to have a factory. I see from Openzeppelin docs v.1 that is possible to create instances of a contract (which end up being not upgradeable):
token = new ERC20("Test", "TST");
But v.4 uses an example in which the initializer function does it:
function initialize() initializer public {
+ __ERC721_init("MyCollectible", "MCO");
}
I was wondering if the following pattern will be good:
My questions are the following:
- What is the proper way to proceed if I build a dapp from which the users have the ability to mint/mintBatch by using the ERC 1155 standard with upgradeability?. Also I see the EIP-1155 standard and it says: "onERC1155Received and onERC1155BatchReceived MUST NOT be called on an EOA (Externally Owned Account).".
- Does this mean this standard is only allowed to transfer between contracts?
- If I want the parent token contract to be upgradeable I'm a bit confused and would appreciate your help a lot...
Code to reproduce
import "./MyERC1155.sol";
import "../node_modules/@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol";
// import './interface/IMyERC1155.sol';
import "../node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "../node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
contract ERC1155Producer is Initializable, ERC1155HolderUpgradeable, OwnableUpgradeable {
constructor() initializer {}
function initialize() initializer public {
__ERC1155Holder_init();
}
function createTokens(address _to, uint256 id, uint256 _amount, bytes memory data) public {
MyERC1155 _myERC1155 = new MyERC1155(); //No need for initialization values right?
_myERC1155.mint(msg.sender, id, _amount, data); // Is this allowed from any wallet?
}
function burn(address _from, uint256 _amount) public {
LomTicket.burn(_from, _amount);
}
}
I hope am being clear enough. Cheers!
Environment
As of now, I'm just designing the contract and I use Hardhat mostly as I see remix don't work very well with upgradeability.