'What is the best way to randomize a selection of minted NFTs in Solidity?
I want to randomize how different levels of NFTs are minted. If there are 3333 in total and 20 Tier 1 (being the best), 313 Tier 2, 1200 Tier 3 and 1800 Tier 4, does the following code do the trick? Could this result in the Tier 1 NFTS being minted every other 4 mints?
function _genTier(uint256 seed) internal view returns (uint256) {
uint256 index = seed % probabilities.length;
uint256 rarity = seed.mul(100).div(MAX_SUPPLY);
if(rarity < probabilities[index]) {
rarity = index;
} else {
rarity = aliases[index];
}
return rarity;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
