CountersUpgradeable.Counter private nonce;
function mintERC721() ... {
uint256 tokenId;
unchecked {
tokenId = (nonce << 128);
}
...
nonce.increment();
}
What does (nonce << 128)
do? seems like it's creating a very large number. Is it a random number within 128 bit that will never collide when nonce increases every time? Why would this be better than a sequential tokenId increase? i.e. 1,2,3,4, etc
function tokenToNonce(uint256 _tokenId) ... {
uint256 nonce = _tokenId >> 128;
if (nonce == 0) {
return 0;
}
return nonce;
}
This one is interesting too, operator now switched to the other way around >>
My understanding is it can find a nonce
based on tokenId
or 0 if tokenId
was not created before?