Giter Club home page Giter Club logo

rarity-analyser's Introduction

Rarity analyser

Creates rarity data for an NFT collection and provides a GraphQL API for making queries.

Creates both classic and normalized rarity scores.

User interface at rarity-interface.

Getting started

Create a MongoDB instance

  1. Create a free MongoDB Atlas instance or use a local MongoDB.

  2. Add the connection string for MongoDB into a .env file:

# .env
MONGODB=mongodb://localhost:27017/rarity

Analyse metadata

Analyse collection metadata with yarn analyse --json <path_to_metadata_json_file>.

Start the GraphQL server

Start the server with yarn dev

Deployment

Heroku

heroku create
heroku config:set MONGODB=mongodb+srv://<user>:<password>@db.b5lu1.mongodb.net/db
git push heroku main

Configuration

Following options can be applied in the rarityConfig.ts file.

weights

Add weights to scale rarity scores up or down.

# rarityConfig.ts
{
  weights: {
    "Trait A": 1.2,
    "Trait B": 0.1,
  }
}

ignoreTraits

Array of trait types to be ignored by the rarity analyser.

{
  ingoreTraits: [
    'Trait x',
    'Trait y',
  ]
}

getMissingTraitIdentifier

(trait_type?: string) => string | undefined

By default it is assumed that the missing traits are completely missing from the attribute list. Some collections however use other values for missing traits, for example "No Hat" for the trait type "Hat".

Example:

# rarityConfig.ts
{
  getMissingTraitIdentifier: (traittype?: string) => "No " + traitType
}

attributesFieldName

The default name is attributes, define a custom name here.

API

analyse

yarn analyse --json <collection.json> --saveJson --db <true> Analyses rarity data form existing metadata

Cli options:

--json

Default: src/data/collection.json Path to the token attribute file

--saveJson

Default: false Saves rarity data into a json file

--db

Default: true Skips saving to database if false

Interfaces

Token
interface Token {
  id: number
  name: string
  attributes: Attribute[] // Attribute field name can be configured in rarityConfig.ts
  image?: string
  description?: string
  image_data?: string
  external_url?: string
  animation_url?: string
  background_color?: string

  // The following fields are included in the analysed data
  rarity_score: number
  rank: number
  rarity_score_normalized: number
  rank_normalized: number
}
Attribute
interface Attribute {
  trait_type: number
  value: string

  // The following fields are included in the analysed data
  rarity_score: number
  rarity_score_normalized: number
  percentile: number
  count: number // Count of how many tokens have the value of this attribute
}

rarity-analyser's People

Contributors

mikoja avatar nick avatar

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.