A revenue distribution tool for Waves nodes
Switch branches/tags
Nothing to show
Clone or download
#4 Compare This branch is 22 commits ahead, 19 commits behind jansenmarc:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
airdrop.js
airdrop_leasers.js
app.js
appng.js
checkPaymentsFile.js
checkpayout.js
gethighfees.js
getnodetx.js
massPayment.js
package.json

README.md

WavesLPoSDistributer

A revenue distribution tool for Waves nodes

Installation

First of all, you need to install Node.js (https://nodejs.org/en/) and NPM. Afterwards the installation of the dependencies could be done via:

mkdir node_modules
npm install

Once the dependencies are installed, the script that generates the payouts need to be configured. In order to do so, change the settings of the configuration section:

/*
    Put your settings here:
        - address: the address of your node that you want to distribute from
        - startBlockHeight: the block from which you want to start distribution for
        - endBlock: the block until you want to distribute the earnings
        - distributableMRTPerBlock: amount of MRT distributed per forged block
        - filename: filename to which the payments for the mass payment tool are written (.json is added automatically)
        - paymentid: id used for administration of the payout.
        - node: address of your node in the form http://<ip>:<port
        - percentageOfFeesToDistribute: the percentage of Waves fees that you want to distribute
 */
var config = {
    address: '',
    startBlockHeight: 462000,
    endBlock: 465000,
    distributableMrtPerBlock: 20,
    filename: 'test',
    paymentid: 1
    node: 'http://<ip>:6869',
    percentageOfFeesToDistribute: 100
}

After a successful configuration of the tool, it could be started with:

node app.js

After the script is finished, the payments that should be distributed to the leasers are written to the file configured by the config.filename setting in the configuration section.

Doing the payments

For the actual payout, the masspayment tool needs to be run. Before it could be started, it also needs to be configured:

/*
 Put your settings here:
 - filename: file to which the payments for the mass payment tool are written
 - node: address of your node in the form http://<ip>:<port>
 - apiKey: the API key of the node that is used for distribution
 */
var config = {
    filename: 'test.json',
    node: 'http://<ip>:<port>',
    apiKey: 'put the apiKey for the node here'
},

After configuration, the script could be started with:

node massPayment.js

Why two seperate tools?

We decided to use two seperate tools since this allows for additional tests of the payments before the payments are actually executed. On the other hand, it does not provide any drawback since both scripts could also be called directly one after the other with:

node apps.js && node massPayment.js

We strongly recommend to check the payments file before the actual payments are done. In order to foster these checks, we added the checkPaymentsFile.js tool that could need to be configured as follows:

/**
 * Put your settings here:
 *     - filename: file to check for payments
 *     - node: address of your node in the form http://<ip>:<port
 */
var config = {
    filename: '',
    node: 'http://<ip>:<port>'
};

After the configuration the checking tool could be executed with:

node checkPaymentsFile.js

The output of the tool should provide an information about how man tokens of each asset will be paid by the payment script. After checking this information, you should be ready to execute the payments.

Airdrops

Payments for airdrops could be calculated by using the airdrop.js script. Configuration works pretty much the same way as for the other scripts:

/**
 * Put your settings here:
 *     - address: the address of your node that you want to distribute from
 *     - block: the block for which you want to calculate your richlist
 *     - total: amount of supply for the reference asset
 *     - amountToDistribute: amount of tokens that you want to distribute (have decimals in mind here...)
 *     - assetId: id of the reference asset
 *     - assetToDistributeId: id of the asset you want to airdrop
 *     - filename: name of the file the payments are written to
 *     - node: address of your node in the form http://<ip>:<port
 *     - excludeList: a list of addresses that should not receive the airdrop, e.g., exchanges...
 */
var config = {
    address: '',
    block: 500859,
    amountToDistribute: 35000000,
    assetId: '',
    assetToDistributeId: '',
    filename: '',
    node: '',
    excludeList: []
};

Afterwards, the script could be started with:

node airdrop.js

Payments for airdrops to leasers could be calculated by using the airdrop_leasers.js script. Configuration works pretty much the same way as for the other scripts:

/**
 * Put your settings here:
 *     - address: the address of your node that you want to distribute from
 *     - total: amount of supply for the reference asset
 *     - amountToDistribute: amount of tokens that you want to distribute (have decimals in mind here...)
 *     - isStatic: boolean to select on which the sending amount is bases, true/false 
 *     			* true: every address receives amountToDistribute
 *     			* false: every address receives his percentage of amountToDistribute based on leased waves    
 *     - assetToDistributeId: id of the asset you want to airdrop
 *     - filename: name of the file the payments are written to
 *     - leasers: name of the file which contains the active leasers info, generated by app.js (LastBlockLeasers.json)
 *     - excludeList: a list of addresses that should not receive the airdrop, e.g., exchanges...
 */
var config = {
    address: '3PEFQiFMLm1gTVjPdfCErG8mTHRcH2ATaWa',
    amountToDistribute: 1,
    assetToDistributeId: '9gnc5UCY6RxtSi9FEJkcD57r5NBgdr45DVYtunyDLrgC', //BearWaves
    filename: 'airdrop_leasers.json',
    leasers: 'LastBlockLeasers.json',
    isStatic: true,
    excludeList: ["3P31zvGdh6ai6JK6zZ18TjYzJsa1B83YPoj"] //Bittrex
};

This example will generate the paymentfile airdrop_leasers.json for sending 1 BearWaves to every leaser in the LastBlockLeasers.json file.

Afterwards, the script could be started with:

node airdrop_leasers.js

Disclaimer

Please always test your resulting payment scripts, e.g., with the checkPaymentsFile.js script!