shadcn.io is not affiliated with official shadcn/ui
Rarity Checker Web3 Block for Svelte
A rarity checker over 200 generated tokens: type a token number to see each trait's share, a rarity score and its rank among all 200, and compare a second token side by side.
Installation
Overview
Find out how rare one token is, with this rarity checker for Svelte with Ark UI. It's Raritylens, an NFT tool, running over Larchquay Tiles, an invented collection of 200 tokens that the page generates itself: five traits each, drawn from weighted lists by a fixed formula, so the same tokens come out every time. Type a token number from 1 to 200 in an Input and a result card shows its sigil, its rank ("Rank 10 of 200, the top 5 %"), the rarity score and a table with each trait's value, its share of the collection counted from the 200, and a bar for its contribution to the score. A second Input, Compare with, fills a second card beside the first. A number that is not a whole number from 1 to 200 gets a problem line under its field, and the cards keep their five rows either way. For collection pages, rarity tools and any place that explains why one token ranks above another.
FAQ
How is the rarity score worked out?
Each trait contributes 1 divided by its share of the collection, and the score is the sum of the five. A value held by 7 of 200 tokens (3.5%) contributes about 28.6; one held by 116 of 200 (58%) contributes about 1.7. Rare traits weigh most, which is the common "rarity score" method. The bar in each row is the contribution as a part of the biggest contribution any value makes.
How is the rank worked out?
The scores of all 200 tokens are compared: the rank is 1 plus the number of tokens with a higher score, so tokens with the same score share a rank, and the top percent is the rank over 200, rounded up. Rank 1 is the rarest.
Where do the tokens come from, and how do I use mine?
PICKS is built at module scope from KINDS, the five trait lists with their weights, and a fixed formula in rollOf, with no random numbers. Shares are counted from those tokens, not typed. In your app replace PICKS with each token's real trait values from your metadata, keep the counting, and change TOTAL to the size of your collection.
What stays local?
All of it. The collection is invented and nothing is read from a chain, a marketplace or an API, so the ranks here say nothing about any real collection.