{"id":15823457,"url":"https://github.com/slippyex/lsp8.app.rarity-lib","last_synced_at":"2025-08-19T13:10:50.228Z","repository":{"id":234395981,"uuid":"788810871","full_name":"slippyex/lsp8.app.rarity-lib","owner":"slippyex","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-19T21:06:15.000Z","size":154,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T04:16:14.751Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slippyex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-19T06:08:37.000Z","updated_at":"2024-04-19T21:05:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"0d52c80c-cfe2-4ecb-8b7c-4bfb425409bc","html_url":"https://github.com/slippyex/lsp8.app.rarity-lib","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"becca88c4289642dc7f75bd90ddedb3504d21c49"},"previous_names":["slippyex/lsp8.app.rarity-lib"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/slippyex/lsp8.app.rarity-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Flsp8.app.rarity-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Flsp8.app.rarity-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Flsp8.app.rarity-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Flsp8.app.rarity-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slippyex","download_url":"https://codeload.github.com/slippyex/lsp8.app.rarity-lib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Flsp8.app.rarity-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271158521,"owners_count":24709083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T08:10:39.737Z","updated_at":"2025-08-19T13:10:50.190Z","avatar_url":"https://github.com/slippyex.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌟 Unlock NFT Traits with LSP8 app Rarity Lib\n\nCraving insights from your Non-Fungible Tokens (NFTs)? Dive deep into the characteristic traits of your collection and bring the hidden gems to the surface with our LSP8 app Rarity Lib. This powerful tool calculates rarity scores, updates a database with these scores, and assigns unique ranks for each NFT.\n\n## Usage\n\n```typescript\nimport { AssetBase, IEquationOptions, calculateRanking } from 'lsp8.app.rarity-lib';\n\nconst assets: AssetBase[] = [\n    {\n        tokenId: '1',\n        tokenName: 'Warrior 1',\n        tokenAttributes: [\n            { key: 'Weapon', value: 'Axe', type: 'STRING' },\n            { key: 'Armor', value: 'Cloth', type: 'STRING' }\n        ],\n        tokenImage: 'https://image.com/1',\n        assetName: 'Excalibur'\n    },\n    {\n        tokenId: '2',\n        tokenName: 'Warrior 2',\n        tokenAttributes: [\n            { key: 'Weapon', value: 'Sword', type: 'STRING' },\n            { key: 'Armor', value: 'Plate', type: 'STRING' }\n        ],\n        tokenImage: 'https://image.com/2',\n        assetName: 'Aegis'\n    },\n    {\n        tokenId: '3',\n        tokenName: 'Warrior 3',\n        tokenAttributes: [\n            { key: 'Weapon', value: 'Wand', type: 'STRING' },\n            { key: 'Armor', value: 'Cloth', type: 'STRING' }\n        ],\n        tokenImage: 'https://image.com/2',\n        assetName: 'Aegis'\n    },\n    {\n        tokenId: '4',\n        tokenName: 'Warrior 4',\n        tokenAttributes: [\n            { key: 'Profession', value: 'Wizard', type: 'STRING' },\n            { key: 'Weapon', value: 'Wand', type: 'STRING' },\n            { key: 'Armor', value: 'Cloth', type: 'STRING' }\n        ],\n        tokenImage: 'https://image.com/2',\n        assetName: 'Aegis'\n    }\n];\n\nconst options: IEquationOptions = {\n    useTraitCount: true,\n    useNormalization: true,\n    algorithm: 'lsp8Generic',\n    nonUniqueRanking: true\n};\n\nconst ranking = calculateRanking(assets, options);\nconsole.log(JSON.stringify(ranking, null, 2));\n\n```\n\nwill result into:\n```json5\n{\n  \"traitFrequencies\": {\n    \"Weapon\": {\n      \"Axe\": 1,\n      \"Sword\": 1,\n      \"Wand\": 2\n    },\n    \"Armor\": {\n      \"Cloth\": 3,\n      \"Plate\": 1\n    },\n    \"TraitCount\": {\n      \"2\": 3,\n      \"3\": 1\n    },\n    \"Profession\": {\n      \"Wizard\": 1\n    }\n  },\n  \"enrichedAssets\": [\n    {\n      \"tokenImage\": \"https://image.com/1\",\n      \"tokenId\": \"1\",\n      \"tokenName\": \"Warrior 1\",\n      \"assetName\": \"Excalibur\",\n      \"score\": 6.666666666666666,\n      \"rank\": 3,\n      \"meta\": {},\n      \"tokenAttributes\": [\n        {\n          \"key\": \"Weapon\",\n          \"value\": \"Axe\",\n          \"percentage\": 25\n        },\n        {\n          \"key\": \"Armor\",\n          \"value\": \"Cloth\",\n          \"percentage\": 75\n        },\n        {\n          \"key\": \"TraitCount\",\n          \"value\": \"2\",\n          \"percentage\": 75\n        }\n      ]\n    },\n    {\n      \"tokenImage\": \"https://image.com/2\",\n      \"tokenId\": \"2\",\n      \"tokenName\": \"Warrior 2\",\n      \"assetName\": \"Aegis\",\n      \"score\": 9.333333333333334,\n      \"rank\": 2,\n      \"meta\": {},\n      \"tokenAttributes\": [\n        {\n          \"key\": \"Weapon\",\n          \"value\": \"Sword\",\n          \"percentage\": 25\n        },\n        {\n          \"key\": \"Armor\",\n          \"value\": \"Plate\",\n          \"percentage\": 25\n        },\n        {\n          \"key\": \"TraitCount\",\n          \"value\": \"2\",\n          \"percentage\": 75\n        }\n      ]\n    },\n    {\n      \"tokenImage\": \"https://image.com/2\",\n      \"tokenId\": \"3\",\n      \"tokenName\": \"Warrior 3\",\n      \"assetName\": \"Aegis\",\n      \"score\": 4.666666666666666,\n      \"rank\": 4,\n      \"meta\": {},\n      \"tokenAttributes\": [\n        {\n          \"key\": \"Weapon\",\n          \"value\": \"Wand\",\n          \"percentage\": 50\n        },\n        {\n          \"key\": \"Armor\",\n          \"value\": \"Cloth\",\n          \"percentage\": 75\n        },\n        {\n          \"key\": \"TraitCount\",\n          \"value\": \"2\",\n          \"percentage\": 75\n        }\n      ]\n    },\n    {\n      \"tokenImage\": \"https://image.com/2\",\n      \"tokenId\": \"4\",\n      \"tokenName\": \"Warrior 4\",\n      \"assetName\": \"Aegis\",\n      \"score\": 11.333333333333332,\n      \"rank\": 1,\n      \"meta\": {},\n      \"tokenAttributes\": [\n        {\n          \"key\": \"Profession\",\n          \"value\": \"Wizard\",\n          \"percentage\": 25\n        },\n        {\n          \"key\": \"Weapon\",\n          \"value\": \"Wand\",\n          \"percentage\": 50\n        },\n        {\n          \"key\": \"Armor\",\n          \"value\": \"Cloth\",\n          \"percentage\": 75\n        },\n        {\n          \"key\": \"TraitCount\",\n          \"value\": \"3\",\n          \"percentage\": 25\n        }\n      ]\n    }\n  ]\n}\n```\n\n## Exemplifying NFT Characteristics with \"TraitCount\"\nAdding a poignant novel trait called \"TraitCount\" to your NFTs is made simple. It mimics the number of traits each NFT possesses.\n\n## Amplify Your Analysis with Trait Frequencies\nEnhance your analysis by studying the frequency of each trait among the NFTs.\n\n![Trait frequency equation](/docs/trait-frequencies.png)\n\n## Rise in Ranks with Rarity Scores\nRarity scores pave the way for ranking your NFTs! This detailed ranking can be either unique or non-unique depending upon your preference.\n\n*Unique Ranks*: Every NFT occupies a unique position in the rank hierarchy based solely on its score.\n\n*Non-Unique Ranks*: NFTs with same scores are assigned same ranks, thereby allowing potential ties.\n\n## Understand Trait Distribution with Trait Percentages\nGet a better understanding of the diversity of your collection by examining the percentage representation of each trait.\n\n![Trait frequency equation](/docs/trait-percentages.png)\n\n## Meet the Universal Equation of LSP8 App!\nThe rarity score is the summation of the rarity of each trait of an NFT. The rarity of a trait reciprocates the trait's frequency.\n\n![Rarity generic equation](/docs/lsp8-generic-equation.png)\n\n# Discover a Spectrum of Support with OpenRarity\n## Harmonic Mean\nDon't let big differences in scores leave you confused. Harmonic Mean simplifies the scenario by dividing the number of scores by the sum of reciprocals of scores.\n\n![OpenRarity harmonic mean equation](/docs/harmonic-mean.png)\n\n## Geometric Mean\nWith Geometric Mean, the 'average' of scores is computed through the product of the numbers.\n\n![OpenRarity geometric mean equation](/docs/geometric-mean.png)\n\n## Weighted Average\nWeighted Average uplifts scores of higher significance, hence adding precision to your analysis.\n\n![OpenRarity weighted average equation](/docs/weighted-average.png)\n\n## Information Content\nInformation Content projects the rarity in terms of information, transforming its basis into a logarithmic scale.\n\n![OpenRarity harmonic mean equation](/docs/information-content.png)\n\n## Sum of Scores\nSimple is often most effective. The Sum of Scores method sums up all scores for an overall rating.\n\n![OpenRarity sum of scores equation](/docs/sum-of-scores.png)\n\n## Normalization and Collection Entropy\nNormalization allows scores to be compared by bringing them within a certain range. \nCollection Entropy measures the diversity or unpredictability of traits within the collection.\n\n![OpenRarity collection entropy](/docs/collection-entropy.png)\n\n## ⚠️ A Word to the Wise\nlsp8-app-rarity-lib aims to offer an open-source library for https://lsp8.app webapp that is easily accessible, user-friendly, and transparent. Feel free to leverage it for your calculations and rankings as well.\n\n## 🤝 Come, Join Us!\nGot suggestions for `lsp8-app-rarity-lib`? Found a bug? We would love to hear from you! Raise an issue or submit a pull request today.\n\n## 📜 License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslippyex%2Flsp8.app.rarity-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslippyex%2Flsp8.app.rarity-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslippyex%2Flsp8.app.rarity-lib/lists"}