Skip to content

jansenmarc/WavesLPoSDistributer

Repository files navigation

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
 *     - alias: the alias of the node address
 *     - startBlockHeight: the block from which you want to start distribution for
 *     - endBlock: the block until you want to distribute the earnings
 *     - firstBlockWithLeases: the block where you received the first lease
 *     - distributableMRTPerBlock: amount of MRT distributed per forged block
 *     - filename: file to which the payments for the mass payment tool are written
 *     - node: address of your node in the form http://<ip>:<port
 *     - percentageOfFeesToDistribute: the percentage of Waves fees that you want to distribute
 *     - blockStorage: file for storing block history
 */

var config = {
    address: '',
    alias: '',
    startBlockHeight: 1800000,
    endBlock: 1820000,
    firstBlockWithLeases: 1800010,
    distributableMrtPerBlock: 20,
    filename: 'test.json',
    node: 'http://<ip>:6869',
    percentageOfFeesToDistribute: 100,
    blockStorage: 'block.json'
}

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

Mass transfer payouts

The generated payout files could now also be used as inputs for mass transfer transactions. this provides a faster and cheaper way to distribute funds.

python massPayment.py

Configuration is done via the configuration section:

'''
    Configuration section:
        privateKey: the private key of the address you want to distribute from
        file: the calculated payout file
        timeout: timeout between requests send to nodes in ms
        assetId: the id of the asset you want to distribute, '' for Waves
        nodes: a list of nodes to which the signed transactions should be send to, in the format: http://host:port
'''
config = {
	'privateKey': '',
	'file': '',
	# timeout between requests in ms
	'timeout': 20,
	'assetId': '',
	'nodes': [
	]
}

Disclaimer

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

About

A revenue distribution tool for Waves nodes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published