Initialize upgradeable ERC721 extending Preset

Question. So I setup the contract like so. Is it okay to initialize it like this? I’m not sure if I need to save the ERC721.intialize somewhere.

contract NFTVendor is Initializable, ERC721PresetMinterPauserAutoIdUpgradeable {

    string public purpose;

    function initialize(

        string memory name,

        string memory symbol,

        string memory baseURI,

        string memory _purpose

    ) public {

        ERC721PresetMinterPauserAutoIdUpgradeable.initialize(

            name,

            symbol,

            baseURI

        );

        purpose = _purpose;

    }
1 Like

Hi @presidento23,

You should add the initializer modifier to your initialize function to ensure it is only called once.

Instead of calling ERC721PresetMinterPauserAutoIdUpgradeable.initialize you should call __ERC721PresetMinterPauserAutoId_init.

See the documentation for more details: https://docs.openzeppelin.com/contracts/3.x/upgradeable#usage

appreciated! this is exactly what I was wondering.

1 Like