Compute the Account Voting Power (Mana) for Accounts on Steem Blockchain using Javascript/NodeJs Function

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

Delegation Service

  1. Voting Algorithm Updated to Favor those High Delegations!
  • Delegate 1000 to justyy: Link
  • Delegate 5000 to justyy: Link
  • Delegate 10000 to justyy: Link

Support me

If you like my work, please:

  1. Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy
  2. Vote @justyy as Witness: https://steemyy.com/witness-voting/?witness=justyy&action=approve
  3. 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

H2
H3
H4
3 columns
2 columns
1 column
6 Comments