new Implementation of ERC721 that removes minting fee or no transaction fee minting.(ERC721FancyMint.sol)
As of today there is two way to mint ERC721 NFTs:
- lazy minting or just in time minting.
- pay the minting fees your self and list them.
I created a way to mint arbitrary number of NFT with no minting fee.
at the heart of any ERC721 there is data storage that hold what token(token Id number) belongs to which Ethereum address.
this is a “Mapping”, Mapping is like a kind of magical table/record, it has a default value for every possible entry.
the default value for addresses are address(0).
as people mint tokens, contract populates the mapping with user address.
An ERC721 contract have to determine which tokens exist.
- for example in ERC721 Implemented by OpenZeppelin the Rationale behind token existence is if a token owner address is 0x000…0000 (also called address(0)) this token does not exist, if anything else the token is exist and owned by that address.
in the image above only the tokenID 0, 1, 2 are exist.
This implementation I need to introduce you to 2 new parameter.
- MaxSupply: total number of token that we want to mint(it can be any number without increasing transaction fee)
- preOwner: the address that we want to mint maxSupply of token to.(maybe the creator)
This Implementation uses a new abstraction for token existence, instead of checking token owner not being address(0) to exist, it check if a token Id is less than MaxSupply it exists, and if the token owner is any address beside address(0) it belong to that address, if the owner was address(0) it belongs to preOwner.
also at deployment make the balance of the user equal to MaxSupply.
In this way preOwner have MaxSupply number of token in their wallet.
Example: If we create a collection with this implementation with the MaxSupply of 999, token 0 to 998 would be exist.
If you want to know more about the Implementation please look at the following links:
- Ethereum Magicians:Idea : minting one billion NFTs or 2^256
- Ethereum Magicians: EIP Draft : mint arbitrary number of tokens(ERC-721) via EIP-2309
- GitHub: EIP-draft_ERC721FancyMint.sol
- no minting fee for any number of token.
- tokens are accessible trough all Ethereum platforms at the same time.(like market places, block explorer,…)
- users can view the tokens before owning them.
Fancy Project : Premeium
I created a collection around this. it has 999 item and the art is on-chain SVG.
and I list them in different market places. something that you can’t do with marketplaces lazy minting contract.
and as I promised they all minted with no transaction.
they have one of the best implementation of batch minting but because of max gas limit of 12 million or 200 token per transaction.
but this way you can bring down the gas usage to zero for any number of token.
the magic happens all with the help of EIP-2309 the consecutiveTransfer event(event is a thing that notify other application that there is something to check for) instead of simple one by one transfer.
consecutiveTransfer of token 0 - 998, are in the transaction log
Fancy Project : Premeium is fully compatible with IERC721 and IERC721Enumerable by using ERC721FancyMint and ERC721FancyMintEnumerable (ERC721FancyMIntEnumerable is a bit too long to explain here)