Try   HackMD

Tutorial Staking-Rewards-Collector

Setup

Windows

Download and install the following programs.

MacOS

  • Install NodeJS for MacOS.
  • Open the terminal app (Note: it could be that you are asked for your password which is your login-password. MacOS hides your password and does not even show that you are inserting any characters. Simply type your password and press enter):
    • Install the Brew package manager by copy&paste the following command (this will take a while)
      • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then install git and yarn from your terminal by running:

  • brew install git
  • brew install yarn

Verify installations:

  • Windows: Press "Windows Key" and type "cmd" and hit enter.
  • MacOS: Open your terminal app.
  • Insert the following commands and press Enter:
    • yarn -v
    • git --version
    • node -v
  • If all commands give you some version number, the programs are correctly installed.

Download code

  • Open / create your preferred folder where you want to download the script into.
  • Open your terminal pointing at that folder:
    • Windows: Right click + shift on the folder and "Open Power Shell Window Here".
    • MacOS: Right click on the folder and "New terminal at folder
      " (if this is not to find, see here)
  • Insert the following command in the terminal and press enter:
    • git clone https://github.com/w3f/staking-rewards-collector.git
  • The files should be cloned (downloaded) into a new folder called "staking-rewards-collector".

Initialize packages

This has only to be done once and directly after you downloaded the script.

  • Open the terminal in the newly cloned folder "staking-rewards-collector"
    • Windows: Shift + right click on the folder and open in the powershell.
    • MacOS: Right click and "New terminal at folder"
  • Insert yarn into the terminal and press enter.
    • This should download all the necessary packages.

Usage

Adjust userInput.json

  • Rename userInput.json.sample file in the config folder to userInput.json.
  • Right-click and open the userInput.json file (inside the config-folder) with any text-editor (code editor is preferred). Here you can specify the necessary information (see for more info the README in GitHub).
  • Input your addresses. Make sure that a new address is added in the following format:
{
    name: "NAME 1",
    address: "Address either of Polkadot / Kusama",
    startBalance: some number (can be set to 0 for most cases),
    network: "Polkadot" / "Kusama" / "Moonriver"
},
{
    name: "NAME 2",
    address: "Address either of Polkadot / Kusama",
    startBalance: some number (can be set to 0 for most cases),
    network: "Polkadot" / "Kusama" / "Moonriver"
},
{
    name: "NAME 3",
    address: "Address either of Polkadot / Kusama",
    startBalance: some number (can be set to 0 for most cases),
    network: "Polkadot" / "Kusama" / "Moonriver"
} <- NO comma if it is the last entry of your addresses
  • NOTE The last entry should not end with a comma and the very last row of the file should end with ]}

Run the script

After you installed everything and set-up your config file, you can run the script to collect your rewards.

  • Open the terminal pointing to your "staking-rewards-collector" folder
  • Type yarn start and press enter.

Updating

  • In the case a new version of the script is available run the git pull command in your terminal (being in the script's folder).
  • This might overwrite your userInput.json file so it is best to give it a new name, run git pull and then replace the downloaded file.

Import the data to Excel

  • Most users are mainly interested in the .csv output files. Those can be imported to Excel as follows:
    • Double click the .csv file to open.
    • Most likely, the data is all pushed into the first column of excel.
    • Select the whole column and go to "Data" on the top and select "Text to Columns"
    • Select "delimited", press next.
    • Only select "Comma" as delimiter, press next.
    • (Only if your operating system uses "," as a decimal delimiter):
      • Go into the "advanced" tab and specify the "." as decimal delimiter and "," as thousand delimiter.
    • Press finish.
    • The data should now be in order and distributed across the columns.