Code Monkey home page Code Monkey logo

non-fungible-ranker's Introduction

non-fungible-ranker

Rank your nft collection choosing the algorithm you prefer. This package can retrieves and parse the collection metadata from different sources and rank every nft using different score strategy.

Install

npm install non-fungible-ranker

Usage

const NFR = require('non-fungible-ranker')

const options = {
    source: {
        type: 'filesystem',
        path: './inputs/json',
    },
    collection: {
        attributes: ['Background','Skin', 'Jowls', 'Mouth', 'Eyes', 'Clothes', 'Headwear'],
        supply: 10000
    },
    ranker: {
        type: 'rarityScore'
    }
}

const ranker = NFR(options)

const stats = await ranker.rankCollection()
console.log(stats)
/*
 * ...
 * { id: '1082.json', score: 0.000001280426016987394 },
 * { id: '1083.json', score: 0.0000013304025676832715 },
 * { id: '1084.json', score: 0.0000013001667264310755 },
 * { id: '1085.json', score: 0.000001254020708824398 },
 * { id: '1086.json', score: 0.0000012871439413840163 },
 * { id: '1087.json', score: 0.0000012583142946898313 },
 * ...
 */

Options

Options must be an object with the following fields

const options = {
    source: { ... },
    collection: { ... },
    ranker: { ... }
}

Source

Source fields must be used to choose and customize a source reader. Each source reader can have different mandatory fields.

Filesystem source reader:
const source = { 
    type: 'filesystem', 
    path: '/home/user/collection/folder' 
}

The path should refer a folder in the filesystem where all the nft metadata json are stored.

Collection

Collection field take care of all the aspect of the nft collection. Only the listed attributes will be used for rank the nft

const collection = { 
    supply: 42, 
    attributes: ['Background', 'Clothes', 'Eyes', 'Fur', 'Har', 'Mouth' ]
}

Ranker

With this field you can choose and customize the rank algorithm

const ranker = { 
    type: 'rarityScore',
}

Available rankers:

  • traitRarity: The simpler algorithm, each nft will be scored based on his rarest trait
  • averageTraitRarity: Sum of the average rarity of every nft traits
  • statisticalRarity: Multiply the nft traits rarities together
  • rarityScore: The commonly used algorithm, each nft will be scored based on the rarity of all his traits on the entire collection

non-fungible-ranker's People

Contributors

palaxx avatar

Watchers

 avatar

non-fungible-ranker's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.