Tutorial: Get the value of your steemit earnings, Part #1

With this post I start a little series that will show you how to get the value of your steemit earnings. This tool can simply be used for your personal interests or of course to create a template for reporting your steemit earnings for a financial office (as we need it in Germany for the tax office).

Note:
The created report is of course not an official document. It is just an idea on how to report your earnings!

The Mission

The requirements for the first part of this series are:

  1. Get the steemit earnings (STEEM, SBD, VESTS) for an account
  2. Create a HTML and CSV report

System Requirements

Visual Studio Code

For developing the program I used the free Code Editor "Visual Studio Code".
You can download it here: https://code.visualstudio.com/

nodeJS

As the runtime system for the program I used "nodeJS" (LTS version).
You can download nodeJS here: https://nodejs.org

Implementation

git repository

You can download the complete sources of this tutorial from my GitHub repository:
https://github.com/SchererF/steemit-earnings

using steemJS API

To get the values of your steemit rewards I used the steem.api.getAccountHistory() function of the steemJS API.

Get Account History

steem.api.getAccountHistory(account, from, limit, function(err, result) {
  console.log(err, result);
});

Source: https://github.com/steemit/steem-js/tree/master/doc

This function expects three parameter as input

  • The account name e.g. 'schererf'
  • The from numeric value: use -1 to get the newest values with the highest identifier first
  • The limit numeric value: the requested amount of data

Note:

  • The from is not -1 the value of limit always has to be greater or equal than from
  • The maximum value for limit is 10000

Because of the maximum value for limit you have to do several calls of the getAccountHistory function to get a complete list of operations for an account.

Example

Get the account history entry of account schererf that has the identifier 15626.

steem.api.getAccountHistory('schererf', 15626, 0, function(err, result) {
  console.log(JSON.stringify(result));
});



Result JSON object:

[[15626,
{"trx_id":"2af66774318058213dab404eb9016697a01f4139",
"block":19828301,
"trx_in_block":63,
"op_in_trx":0,
"virtual_op":0,
"timestamp":"2018-02-13T08:05:39",
"op":["claim_reward_balance",
{"account":"schererf",
 "reward_steem":"0.000 STEEM",
 "reward_sbd":"21.246 SBD",
 "reward_vests":"14086.296566 VESTS"}]}]]

This entry shows my rewards of 21.246 SBD and 14086.296566 VESTS that I have claimed on 2018-02-13 08:05:39.

There are different values for the Operation type (op) but to get the earnings we only need the entries of type 'claim_reward_balance'. I also included the entries of type 'transfer' for further evaluations.

Let's do it

Download the sources

Just go to my GitHub repository and Download ZIP
https://github.com/SchererF/steemit-earnings

Extract the downloaded zip to your preferred folder.

Open Node.js command prompt

Open the the "Node.js command prompt" and change to the folder of the extracted program.

Install the required packages of the program

For implementation I used several node packages :

  • steem: The steem JS API
  • fs: To create the output files
  • bluebird: Fully featured promises library
  • node-fetch: Brings 'window.fetch' to Node.js

Just execute the following command to install all required packages for the program.

npm install

Run the program

To run the program you just have to enter

node get-claimed-rewards.js "accountname"

(e.g.)
node get-claimed-rewards.js schererf

The program request all account history data for the specified account and creates a HTML and a CSV file as output.

Take a look at the output HTML

The created HTML uses the bootstrap-framework and looks like this.

By clicking on the "claim_reward_balance..." button you can see the JSON data of the underlying history entry.

Tutorial Preview

In the next parts of this little series we will have a look at how to get the Steem Power (SP) value for the VESTS reward and how to report the STEEM and SBD earnings as EUR/USD based on the historical exchange rate of the reward claim date.

Please give me feedback if this tutorial was helpful for you.

Thanks for reading and watching,
@schererf

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
22 Comments