I've just implemented several SCs in order to accomplish the ERC721 functionality but I'm facing a critical issue related to the scalability when I want to create a great number of tokens. I'm storing all the data regarding uniques tokens through IPFS platform, thus when I create a token I push this identifier to 2 different arrays and set the IPFS hash into several tokens (I want to add the same IPFS hash to several tokens). But the gas cost is too high, so I wonder if there is a better way to achieve my outcome of creating at least 100 tokens in each transaction. I've tested with 50 tokens and the gas cost is around 7 mill. Furthermore, I'm going to increase the gas per block.
function _mint(
address _to,
uint256[] _tokenIds,
string _dataId
) internal
{
for (uint256 x = 0; x < _tokenIds.length; x++) {
// Add the token ID to the owner token array
super._mint(_to, _tokenIds[x]);
// Add to the token ID to the tokens array
allTokens.push(_tokenIds[x]);
// Add token data
setTokenData(_tokenIds[x], _dataId);
}
}
PD: Do you think it makes sense to use it when you need to create 10k of tokens every day?
Thanks in advance!