SteemJs for Dummies #10: VotingsteemCreated with Sketch.

in #utopian-io7 years ago

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



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @stoodkev I am @utopian-io. I have just upvoted you!

Achievements

  • WOW WOW WOW People loved what you did here. GREAT JOB!
  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • You are generating more rewards than average for this category. Super!;)
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.21
TRX 0.25
JST 0.038
BTC 95830.75
ETH 3363.86
USDT 1.00
SBD 3.08