SteemJs for Dummies #10: Voting by stoodkev

View this thread on steempeak.com
· @stoodkev ·
$39.56
SteemJs for Dummies #10: Voting
![image.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1512066899/i4dumpo8sz6a6yx2qlcp.png)
<br>
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](https://github.com/steemit/steem-js/tree/master/doc#votes)

~~~~
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


<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@stoodkev/steemjs-for-dummies-10-voting">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 23 others
properties (23)
post_id19,142,982
authorstoodkev
permlinksteemjs-for-dummies-10-voting
categoryutopian-io
json_metadata"{"type": "tutorials", "repository": {"id": 63857882, "watchers": 179, "events_url": "https://api.github.com/repos/steemit/steem-js/events", "forks": 67, "name": "steem-js", "issues_url": "https://api.github.com/repos/steemit/steem-js/issues{/number}", "trees_url": "https://api.github.com/repos/steemit/steem-js/git/trees{/sha}", "fork": false, "git_url": "git://github.com/steemit/steem-js.git", "assignees_url": "https://api.github.com/repos/steemit/steem-js/assignees{/user}", "size": 11336, "owner": {"id": 17434692, "following_url": "https://api.github.com/users/steemit/following{/other_user}", "starred_url": "https://api.github.com/users/steemit/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/steemit/subscriptions", "repos_url": "https://api.github.com/users/steemit/repos", "login": "steemit", "gists_url": "https://api.github.com/users/steemit/gists{/gist_id}", "followers_url": "https://api.github.com/users/steemit/followers", "received_events_url": "https://api.github.com/users/steemit/received_events", "type": "Organization", "avatar_url": "https://avatars3.githubusercontent.com/u/17434692?v=4", "site_admin": false, "organizations_url": "https://api.github.com/users/steemit/orgs", "gravatar_id": "", "events_url": "https://api.github.com/users/steemit/events{/privacy}", "url": "https://api.github.com/users/steemit", "html_url": "https://github.com/steemit"}, "forks_count": 67, "git_refs_url": "https://api.github.com/repos/steemit/steem-js/git/refs{/sha}", "blobs_url": "https://api.github.com/repos/steemit/steem-js/git/blobs{/sha}", "pushed_at": "2017-11-29T16:10:41Z", "watchers_count": 179, "teams_url": "https://api.github.com/repos/steemit/steem-js/teams", "comments_url": "https://api.github.com/repos/steemit/steem-js/comments{/number}", "archived": false, "svn_url": "https://github.com/steemit/steem-js", "merges_url": "https://api.github.com/repos/steemit/steem-js/merges", "subscribers_url": "https://api.github.com/repos/steemit/steem-js/subscribers", "issue_events_url": "https://api.github.com/repos/steemit/steem-js/issues/events{/number}", "stargazers_url": "https://api.github.com/repos/steemit/steem-js/stargazers", "mirror_url": null, "statuses_url": "https://api.github.com/repos/steemit/steem-js/statuses/{sha}", "has_projects": true, "milestones_url": "https://api.github.com/repos/steemit/steem-js/milestones{/number}", "description": "Steem.js the official JavaScript library for Steem blockchain", "keys_url": "https://api.github.com/repos/steemit/steem-js/keys{/key_id}", "open_issues": 39, "compare_url": "https://api.github.com/repos/steemit/steem-js/compare/{base}...{head}", "ssh_url": "git@github.com:steemit/steem-js.git", "license": {"name": "MIT License", "key": "mit", "url": "https://api.github.com/licenses/mit", "spdx_id": "MIT"}, "html_url": "https://github.com/steemit/steem-js", "commits_url": "https://api.github.com/repos/steemit/steem-js/commits{/sha}", "open_issues_count": 39, "stargazers_count": 179, "branches_url": "https://api.github.com/repos/steemit/steem-js/branches{/branch}", "full_name": "steemit/steem-js", "forks_url": "https://api.github.com/repos/steemit/steem-js/forks", "score": 102.26825, "deployments_url": "https://api.github.com/repos/steemit/steem-js/deployments", "contributors_url": "https://api.github.com/repos/steemit/steem-js/contributors", "homepage": "https://www.npmjs.com/package/steem", "contents_url": "https://api.github.com/repos/steemit/steem-js/contents/{+path}", "has_downloads": true, "collaborators_url": "https://api.github.com/repos/steemit/steem-js/collaborators{/collaborator}", "created_at": "2016-07-21T09:54:16Z", "git_commits_url": "https://api.github.com/repos/steemit/steem-js/git/commits{/sha}", "releases_url": "https://api.github.com/repos/steemit/steem-js/releases{/id}", "private": false, "pulls_url": "https://api.github.com/repos/steemit/steem-js/pulls{/number}", "git_tags_url": "https://api.github.com/repos/steemit/steem-js/git/tags{/sha}", "notifications_url": "https://api.github.com/repos/steemit/steem-js/notifications{?since,all,participating}", "language": "JavaScript", "updated_at": "2017-11-29T06:01:02Z", "has_wiki": false, "downloads_url": "https://api.github.com/repos/steemit/steem-js/downloads", "hooks_url": "https://api.github.com/repos/steemit/steem-js/hooks", "languages_url": "https://api.github.com/repos/steemit/steem-js/languages", "default_branch": "master", "labels_url": "https://api.github.com/repos/steemit/steem-js/labels{/name}", "url": "https://api.github.com/repos/steemit/steem-js", "has_pages": false, "tags_url": "https://api.github.com/repos/steemit/steem-js/tags", "clone_url": "https://github.com/steemit/steem-js.git", "archive_url": "https://api.github.com/repos/steemit/steem-js/{archive_format}{/ref}", "has_issues": true, "issue_comment_url": "https://api.github.com/repos/steemit/steem-js/issues/comments{/number}", "subscription_url": "https://api.github.com/repos/steemit/steem-js/subscription"}, "pullRequests": [], "format": "markdown", "image": ["https://res.cloudinary.com/hpiynhbhq/image/upload/v1512066899/i4dumpo8sz6a6yx2qlcp.png"], "links": ["https://res.cloudinary.com/hpiynhbhq/image/upload/v1512066899/i4dumpo8sz6a6yx2qlcp.png", "https://github.com/steemit/steem-js/tree/master/doc#votes"], "app": "utopian/1.0.0", "platform": "github", "tags": ["utopian-io", "steemdev", "opensource", "news", "steemjs"], "community": "utopian", "users": ["stoodkev"]}"
created2017-11-30 18:51:51
last_update2017-11-30 18:51:51
depth0
children2
net_rshares15,035,744,312,836
last_payout2017-12-07 18:51:51
cashout_time1969-12-31 23:59:59
total_payout_value29.311 SBD
curator_payout_value10.244 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length2,117
author_reputation89,353,405,873,727
root_title"SteemJs for Dummies #10: Voting"
beneficiaries
0.
accountfreedom
weight658
1.
accountknowledges
weight41
2.
accountmisterdelegation
weight546
3.
accountruah
weight59
4.
accounttransisto
weight70
5.
accountutopian-io
weight542
6.
accountwackou
weight52
7.
accountxeldal
weight27
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars0
author_curate_reward""
vote details (87)
@emrebeyler ·
Thank you for the contribution. It has been approved.

You can contact us on [Discord](https://discord.gg/UCvqCsx).
**[[utopian-moderator]](https://utopian.io/moderators)**
properties (22)
post_id19,152,722
authoremrebeyler
permlinkre-stoodkev-steemjs-for-dummies-10-voting-20171130t211726603z
categoryutopian-io
json_metadata"{"app": "busy/1.0.0", "community": "busy", "tags": ["utopian-io"]}"
created2017-11-30 21:17:27
last_update2017-11-30 21:17:27
depth1
children0
net_rshares0
last_payout2017-12-07 21:17:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length172
author_reputation319,480,565,467,431
root_title"SteemJs for Dummies #10: Voting"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@utopian-io ·
### 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. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**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**
properties (22)
post_id19,252,065
authorutopian-io
permlinkre-stoodkev-steemjs-for-dummies-10-voting-20171202t020806893z
categoryutopian-io
json_metadata"{"app": "utopian/1.0.0", "community": "utopian", "tags": ["utopian-io"]}"
created2017-12-02 02:08:06
last_update2017-12-02 02:08:06
depth1
children0
net_rshares0
last_payout2017-12-09 02:08:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,216
author_reputation152,913,012,544,965
root_title"SteemJs for Dummies #10: Voting"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000