Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Valid

Rarity of tokens is not respected due to random_words[0] % 3

Rarity of tokens is not respected due to random_words[0] % 3

All types are equally rare in the given implementation because of the lines shown here.

rarity: uint256 = random_words[0] % 3
self.tokenIdToRarity[ERC721._total_supply()] = rarity

The desired behavior is to make rarity weighted as follows :-

x: uint256 = random_words[0] % 100
rarity: uint256 = 0
if x >= 95:
rarity = LEGEND
elif x >= 70:
rarity = RARE
else:
rarity = COMMON
self.tokenIdToRarity[ERC721._total_supply()] = rarity

Tools

Manual

Updates

Lead Judging Commences

inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Rarity is 1/3 instead of what the docs say

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.