I'm using the ERC721 preset from Open Zeppelin. If I'm understanding the contract correctly, one of the main differences from the standard ERC721 is that the latter only has to be deployed once and anybody can call the mint function without any access control:

function _mint(address to, uint256 tokenId) internal virtual {
    require(to != address(0), "ERC721: mint to the zero address");
    require(!_exists(tokenId), "ERC721: token already minted");
    _beforeTokenTransfer(address(0), to, tokenId);
    _balances[to] += 1;
    _owners[tokenId] = to;
    emit Transfer(address(0), to, tokenId);

whereas the preset requires a new contract to be deployed each time a new token is minted. And only the deployer of the contract has the access to call the function:

function mint(address to) public virtual {
    require(hasRole(MINTER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have minter role to mint");
    _mint(to, _tokenIdTracker.current());

Is this correct? If so, does this mean all of the dependencies of the preset like following have to be deployed each time a new token is to be minted adding to the cost of the gas?

import "../ERC721.sol";
import "../extensions/ERC721Enumerable.sol";
import "../extensions/ERC721Burnable.sol";
import "../extensions/ERC721Pausable.sol";
import "../../../access/AccessControlEnumerable.sol";
import "../../../utils/Context.sol";
import "../../../utils/Counters.sol";

Not sure if I'm missing something, but if the main selling point of the preset is the token ID and URI autogeneration, this seems like a minor gain in exchange for an exorbitant cost of the gas in the deployment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.