Is it possible to create many ERC721 tokens at a time? I saw this link. ERC721 - Create 1000 tokens in one function call But I don't get it. Please help me.
2 Answers
Yes you can create many ERC721 tokens at a time, however, the amount of tokens that you can create from a single function call is dependant on the gas cost of your transaction. If your transaction costs more than the gas limit i.e. approx 8000000 then your function will not be successful.
Yes you can, with the use of clone contract ERC-1167. Here is an simple example that i have written times ago:
function mint(uint256 _numberOfToken) public onlyOwner returns(address[] memory) {
require(_numberOfToken < 30);
address[] memory output = new address[](_numberOfToken);
for(int i = 0; i < _numberOfToken; i++) {
returnAddress[i] = createClone(YOUR_CORE_ERC721_ADDRESS_HERE);
}
emit createNewToken(returnAddress)
return returnAddress;
}
with createClone function is take from ERC1167 implementation
So in the idea in general first you deploy your main ERC721 and deploy another contract which create clones from your main ERC721. When you want to create many new ERC721 you just call that contract and get the return value.
Btw the reason i put 30 as maxium is because this function cost a lot of gas and if like an user try to call for 100 then the code is gonna break so i just want a call to just have 30 token at maxium.