SteemJs for Dummies #10: Voting

Words
120
Reading
1 min
Listen
Play
9y

image.png


A little bird made me notice that I started explaining more complicate features of SteemJs although I haven't shown how to vote yet.

It is a very easy process knowing which you can design for example a voting slider for minnows (This is how SteemPlus started ;) ). Anyways, let's get to it and as usual, check the documentation

steem.broadcast.vote(wif, voter, author, permlink, weight, function(err, result) {
  console.log(err, result);
});

Simply use this as the following:

  • wif is the private posting key, that you can find under the Permissions tab of your wallet. Click on show the private key and copy paste it here.
  • voter is the account corresponding to that wif key, the person voting.
  • author is the author of the blog (or comment) you wish to vote for.
  • permlink : be careful here, it's not the entire url but only the last part of it, after the last /
  • weight, the weight goes to two decimals so multiply your percentage by 100 : 99.99%= 9999. This corresponds to the percentage at which you are actually voting.

Okay, that was a bit too easy so let's also see how to get specifically the votes for a post. Use it in the same manner than above, and it will return the list of votes, their authors, weights and r_shares.

steem.api.getActiveVotes(author, permlink, function(err, result) {
  console.log(err, result);
});

You can also get the last upvotes from a specific account by using this function:

steem.api.getAccountVotes(voter, function(err, result) {
  console.log(err, result);
});

voter stands from the account you wish to look out. It will return the list of the last votes.

That was a quick episode. Stay tuned for next one ;)

Hope this helps!

stoodkev@stoodkev



Posted on Utopian.io - Rewarding Open Source Contributors

SteemJs for Dummies #10: Voting | Ecency