A few days ago I was writing a seemingly simple script for the @Rabona Curation Program. The script was supposed to simply calculate the USD vote values of all the Curation Followers, and sum them up to find out what is the total USD value of the Curation Trail. Simple enough, right?
Well, easier said than done. What actually happened is that I have been somewhat struggling to achieve that, for multiple reasons:
Lack of proper documentation. I think the entire Hive ecosystem lacks a proper and comprehensive documentation, especially the technical documentation. Often times a developer is on their own, with some bits of information here, maybe some code samples there, but nothing thorough.
I don't want to complain. I work as a Software Engineer myself and I know it takes crazy amount of work to do everything right: develop, maintain, document.
Hopefully this situation will improve in the future, and I will try to do my part as well—if I only can! This post will hopefully be a brick in this wall :)
Outdated libraries. I wanted to calculate the USD vote value in a Python app, so I immediately though that maybe the
beem
library has a simple method to do it. And it does, but these methods (beem.account.Account.get_voting_value
andbeem.account.Account.get_voting_value_SBD
) seem to be outdated and do not return proper values.It is not a secret that the
beem
library is not the most maintained one. The original developer no longer actively works on it, although there have been some updates pushed by the community. But I don't want to focus onbeem
itself, but rather treat it as an example of a bigger problem. There are many Hive-related libraries written for various programming languages and solving various problems, which are abandoned and no longer maintained. Relying on them is risky at best.
These problems mean that it is much harder for a developer to start building something new for the Hive blockchain, as they have to do a lot of digging and rummaging, and rely on very low-level solutions (which are hard to maintain and take more time to implement).
I feel that my struggle with calculating the vote value partly came from these exact issues that I described. While searching through Hive to find whether someone had similar issues and maybe shared a solution of some sort, I stumbled upon a post from almost a half year ago written by @cryptosharon, describing the very same struggle that I had.
I left a comment under that post just to share my difficulties, but later I managed to finally implement the estimation of the USD vote value. I promised to share my solution, which I have rewritten from Python to JavaScript.
* * *
The code is fairly simple and it follows the formula available within the Official Hive.io documentation. As far as I understand it, it users the current reward fund and user's VESTS to calculate how much of that fund the user is able to direct towards a post by upvoting. Then this tiny bit of the reward fund is converted from the native cryptocurrencies (HIVE and HBD) into the USD price.
I cross-checked the results of this script with platforms like hivestats.io and it seems to work. If you find any issues with it, though, or have any questions—feel free to ask!