i am new to blockchain , trying to implement lazy minting. but still did not succeeded. i read many articles and watch youtube videos , but did not getting the concept of how the lazy-minting is implemented with help of EIP-712. what exactly is eip-712 is doing , why we creating a file in javaScript to make vouchers etc.
-
Do you mean EIP-721, the NFT standard instead of EIP-712? Lazy minting doesn't require anything other than ERC-721.– Martijn VissersCommented Sep 8, 2022 at 8:53
-
@MartijnVissers can i do lazyMinting with help of ERC-1155 ?– Umar RazaCommented Sep 8, 2022 at 10:22
-
I just updated my answer to include ERC-1155.– Martijn VissersCommented Sep 8, 2022 at 12:32
2 Answers
welcome to EthereumSE!
Lazy minting doesn't require EIP-712. It's just a modification to ERC-721. It's implemented by simply allowing a user to mint the tokens themselves by overriding the safeMint
function to be public
.
In most cases you'd want to add some limits to how many tokens can be minted, and allow payment to be made by making the function `payable'
private uint256 _tokenIdCounter = 0;
function safeMint() public payable {
_safeMint(msg.sender, _tokenIdCounter);
_tokenIdCounter = _tokenIdCounter + 1;
}
In this case we use a _tokenIdCounter
to set the tokenId which is just a number that increments automatically after each mint.
For ERC-1155 tokens, it's nearly the same. You have to override the minting functions with public ones that call the internal function to mint.
function mint(address account, uint256 id, uint256 amount, bytes memory data)
public
onlyOwner
{
_mint(account, id, amount, data);
}
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
public
onlyOwner
{
_mintBatch(to, ids, amounts, data);
}
yes lazy minting require EIP standard for verification. concept of lazy minting is to save creators from gas fees. and once buyer purchase the NFT marketplace call the minting function along with buyer address. all these data in voucher and voucher verification is do using EIP.