Previously, we learn how to use Javascript/NodeJs function to compute the real downvote mana/power for accounts on steem blockchain via the steem.api.getAccounts API. Today, we are going to compute the upvote mana/power instead.
Computing the upvote mana/power for accounts on Steem Blockchain is a bit easier than the downvote power. We still need to apply the restored mana since users' last upvoting activity.
function getUpvotePower(id) {
return new Promise((resolve, reject) => {
steem.api.getAccounts([id], function(err, response) {
if (err) reject(err);
const secondsago = (new Date - new Date(response[0].last_vote_time + "Z")) / 1000;
let vpow = response[0].voting_power + (10000 * secondsago / 432000);
resolve(Math.min(vpow / 100, 100).toFixed(2));
});
});
}
(async function() {
const val = await getUpvotePower('justyy');
log(val);
})();
Run this code on Steem JS Editor.
Similarly, the function returns a promise so that you can use await in an async function.
To compute the downvote power/mana: Javascript (NodeJS) Function to Get the Downvote Power of Account on Steem Blockchain
Reposted to Blog
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thank you for reading ^^^^^^^^^^^^^^^
NEW! Following my Trail (Upvote or/and Downvote)
Follow me for topics of Algorithms, Blockchain and Cloud.
I am @justyy - a Steem Witness
https://steemyy.com
My contributions
- Steem Blockchain Tools
- Computing & Technology
- Download Youtube Video
- Find Cheap & Bargin VPS: VPS Database
- Online Software and Tools
- Online File/Video Merger
Delegation Service
Support me
If you like my work, please:
- Buy Me a Coffee, Thanks!
- Become my Sponsor, Thanks!
- Voting for me:
https://steemit.com/~witnesses type in justyy and click VOTE
- Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy
- Vote @justyy as Witness: https://steemyy.com/witness-voting/?witness=justyy&action=approve
- Set @justyy as Proxy: https://steemyy.com/witness-voting/?witness=justyy&action=proxy
Alternatively, you can vote witness or set proxy here: https://steemit.com/~witnesses