Giter Club home page Giter Club logo

dot-validator-selector's Introduction

dot-validator-selector

Get the best staking validators programmatically.

Introduction

Selecting validators for staking your DOT/KSM is an arduous process and one that is uncertain and confusing for most users. The aim of this module is to auto select validators based on the criteria below so that the user doesn't have to. Since most users are not well versed in knowing which validators are best, this module should make a better decision on average without the time commitment necessary to select your own.

Criteria

This program selects validators based on the following criteria:

  • Their identity is verified
  • Their commission is within an acceptable range e.g. no less than 0.5% and no greater than 20%
  • The validator is not oversubscribed, allowing you to earn rewards as a nominator
  • The validator has skin in the game, represented by their own stake e.g. they have deposited 1000 DOT of their own capital
  • Each validator is run by a unique entity
  • The validator has never been slashed
  • The validator is currently elected to validate transactions and earn rewards

Further reading here.

Getting started

Install the modules with npm i & run the tests with npm run test.

You can also download the module via NPM.

Usage

js

// initialise the polkadot api object 
const { ApiPromise, WsProvider} = require("@polkadot/api");
const api = await ApiPromise.create({ provider: new WsProvider("YOUR_PROVIDER") });

// initialise the selector
const selector = new ValidatorSelector(api, MAX_COMMISSION, MIN_STAKING, ERA); // set ERA to 0 or undefined if you want to use the current era

// get n number of validators matching the criteria
selector.getValidators(n);

> [{ "accountId": "1REAJ1k691g5Eqqg9gL7vvZCBG7FCCZ8zgQkZWd4va5ESih", "identity": { "additional": [], "display": { "raw": "0x506f6c6b61646f742e70726f202d205265616c676172" }, "legal": { "none": null }, "web": { "raw": "0x68747470733a2f2f706f6c6b61646f742e70726f" }, "riot": { "raw": "0x407265616c6761723a6d61747269782e6f7267" }, "email": { "raw": "0x68656c6c6f40706f6c6b61646f742e70726f" }, "pgpFingerprint": null, "image": { "none": null }, "twitter": { "raw": "0x4070726f706f6c6b61646f74" } }, "staked": 156300000000, "commission": "1%" }, ...]

// check if a user's validators are meeting the criteria
selector.getUserValidatorsMeetCriteria(userAccountId);

> [{ "accountId": "13mK8AssyPekT5cFuYQ7ijKNXcjHPq8Gnx6TxF5eFCAwoLQ", "match": false }, ...]

via cURL

Cached snapshots of a particular era can be retrieved via cURL:

$ curl https://raw.githubusercontent.com/James-Sangalli/dot-validator-selector/gh-pages/cache/ksm/2851.json 

Example output:

> [{"accountId":"F7hDMvu33u14QPXbkBzqF4CuuyyruB2xi6D3V7aUbY8KGpr","identity":{"additional":[],"display":{"raw":"0x53796e6572576f726b20496e63"},"legal":{"none":null},"web":{"none":null},"riot":{"none":null},"email":{"raw":"0x7374616b696e674073796e6572776f726b2e636f6d"},"pgpFingerprint":null,"image":{"none":null},"twitter":{"none":null}},"staked":98500000000000,"commission":"2%"}, ...]

See a sample

If you want to see this module in action for Polkadot or Kusama, you can try it out here. It will randomly select 16/24 validators meeting the criteria for Polkadot/Kusama.

Cached validators

Since this module can be slow to select validators, it is possible to cache them for the current era using npm run updateCache and then retrieve them as above with the cURL instructions. You can see some examples in the cache folder here.

Tip

Thank you to the treasury for this tip!

dot-validator-selector's People

Contributors

bitcoinwarrior1 avatar paradox-tt 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.