Hi everyone today we explain about the possibility to use the Steem Api to broadcast a comment on a specific user post.
I use the comment on the @steemrepo project because our curators choose good quality posts and can make the upvote/comment on a post directly by our discord server:
We use discord because we take this two var used on the script:
Author: the post author
Permlink: the link of the post author
Requirements
Installing the libraries:
sudo apt-get install nodejs
sudo apt-get install npm
npm install steem --save
Write the Code
var steem = require("steem");
var wifkey = youprivatepostingkey;
var author = postauthor;
var permlink = thelinkoftheposttocommenton;
var author1 = theuserwewillusetocomment;
steem.broadcast.comment(
wifkey,
author, // Parent Author
permlink, // Parent Permlink
author1, // Author
steem.formatter.commentPermlink(author, permlink),
'', // Title
'The comment you wanna add on a post' , // Body,
{ tags: ['test'], app: `steemjs/examples` }, // Json Metadata
function(err, result) {
console.log(err, result);
}
);
Explain the variables
To comment on a specific user post we use the steem.js functions called
"steem.broadcast.comment"
"steem.formatter.commentPermlink"
- wifkey = the private posting key of the users we are using to comment
- author = called Parent Author is the author of the post we are commenting on
- permlink = is exactly the url we are commenting on
- Author1 = is the username related to the wifkey we are using to comment
Let me do an example:
Imagine you are @yanosh01 and you want to comment this @steemrepo post:
https://steemit.com/steemrepo/@steemrepo/steemrepo-rewarding-undervalued-content-creators
it will be:
- wifkey = the private posting key of yanosh01
- author = steemrepo
- permlink = steemrepo-rewarding-undervalued-content-creators
- Author1 = yanosh01
I just found your account today. I appreciate these short tutorials. They are useful to a new developer like me. I am working towards building multiple projects connected to the Steem blockchain.
It's a pleasure. My focus is on javascript, so if you need any help you can contact me on @steemrepo Discord server or on Developers Discord server. Feel free to ask me whatever you need!!!
I will definitely reach out. My main account is @nikema here and on discord. Thank you so much!
You got a 3.23% upvote from @postpromoter courtesy of @yanosh01!
Want to promote your posts too? Check out the Steem Bot Tracker website for more info. If you would like to support the development of @postpromoter and the bot tracker please vote for @yabapmatt for witness!