Steem.js: Comment, upvote, downvote, transfert. You wanted it, you got it.

in #steemjs8 years ago (edited)


Credit @klye

Hey developers, here is the news: Now you can upvote, downvote, comment and tranfert using Steem.js!

Here the package:

https://github.com/adcpm/steem
https://www.npmjs.com/package/steem

Here the examples:

UpVote

/* @params username, password, author, permlink, weight */
steem.broadcast.upvote('fabien', 'sgs56sd84hbr51qpodg1', 'steemjs', 'permlink-of-the-post', 10000, function(err, result) {
    console.log(err, result);
});

DownVote

/* @params username, password, author, permlink, weight */
steem.broadcast.downvote('fabien', 'sgs56sd84hbr51qpodg1', 'steemjs', 'permlink-of-the-post', 10000, function(err, result) {
    console.log(err, result);
});

Post

/* @params username, password, parentAuthor, parentPermlink, author, permlink, title, body, jsonMetadata */
steem.broadcast.comment('fabien', 'sgs56sd84hbr51qpodg1', 
 '', 
 'steemjs',
 'fabien', 
 'this-is-the-slug-of-my-article', 
 'This is the title', 
 'This is the body', 
 {tags: ['steemjs', 'steem']}, 
 function(err, result) {
    console.log(err, result);
});

Transfer

/* @params username, password, from, to, amount, memo */
steem.broadcast.transfer('fabien', 'sgs56sd84hbr51qpodg1', 'you', 'steemjs', '50.000 SBD', 'Donation', function(err, result) {
    console.log(err, result);
});

Thank's to @heimindanger who helped for the methods and browser side support. You also want to contribute and get rewarded for that? Contact me on the rocket chat @fabien or channel #steemjs.

More will come, stay tuned.

PS : This is not my real password on examples ;)

Fabien

Sort:  

How to check the balance

For anyone else finding this now, like me, it's changed:

  /** Broadcast a vote */
  steem.broadcast.vote(
    postingWif,
    username, // Voter
    'firepower', // Author
    'steemit-veni-vidi-vici-steemfest-2016-together-we-made-it-happen-thank-you-steemians', // Permlink
    10000, // Weight (10000 = 100%)
    function(err, result) {
      console.log(err, result);
    }
  );

Thank you very helpful!

Hi Yoghurt,

Could you please advise me how to downvote by using steem.broadcast.vote()? I did set weight to 0, but it seems a bad practice

Thank you so much for any help

Really cool thing !!! It must be upvoted

Thanks for commissioning the artwork @fabien!

Awesome work with this Javascript Library!
(I actually dabble in code, so I appreciate this!)

Awesome work @fabien thank you for your efforts :)

nice post.. this is what im looking. thanks

Thks for making developpers work easy.

This post has been linked to from another place on Steem.

About linkback_bot

Now you're talking my language!

But how does one specify whether the post is a standalone post or a comment?

By not including a parent permlink, it will be a main post, conversely, by including a parent permlink, it will be a comment under a post (the post or the comment above it identified by the parent permlink). Late answer here, but somebody may find this handy someday.

Thanks, I did figure it out eventually, but as you say, others will surely find it helpful!