[Hive Patched] Steem Bot - Curation Trail Bot
(Want to use the logo yourself? no problem, checkout the post I made about My Art Design For Hive Logo)
Repository:
https://www.npmjs.com/package/steem-js-patched
All of this tutorial is patched for Hive, so it works for Hive and steem!
All of the examples and results is from the old tutorial but still same for hive!
Helpful tutorials:
[HIVE Patched] SteemJS Full Tutorial - All The Functions - All The Abilities
[Hive Patched Tutorial] SteemJS - Vote, Comment and Follow functions - All In One
Hello guys and welcome back to the tutorials series SteemBots
so let's start, install steemjs library - npm install steem-js-patched --save and open new document app.js
var steem = require('steem-js-patched');
now add a few variables
//This User Is Official Steem-JS guest user, you can only post and vote through the Posting WIF.
const ACC_NAME = 'guest123',
ACC_KEY = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg',
TARGET = 'appreciator',
MINIMUM = 10; //100% = 10000, 10% = 1000
the account name,
the account posting private key,
the target (who we're going to follow the votes with),
minimum is the minimum percentage we're giving.
add the RPC node to switch the API for Hive API
steem.api.setOptions({ url: 'https://api.hive.blog' });
console.log("SteemBots @lonelywolf");
console.log("Curation Trail Bot Running...");
console.log("Waiting for votes from @" + TARGET);
now we need to add the voting function
function StreamVote(author, permalink, weight) {
steem.broadcast.vote(ACC_KEY, ACC_NAME, author, permalink, weight, function(err, result) {
console.log('Voted Succesfully, permalink: ' + permalink + ', author: ' + author + ', weight: ' + weight / 100 + '%.');
});
}
because we already set the account name and key we don't need to take it from the function and all we do is to broadcast the vote to the steem blockchain with the author, permalink and weight and then send a comment to the console.
now we need to get the transactions that go through the blockchain
steem.api.streamTransactions('head', function(err, result){
});
- because we're getting the data from the stream transactions of the blockchain it will stay updated and just wait for the target account to vote
now we need to get the type of the transactions and the data
const type = result.operations[0][0];
const data = result.operations[0][1];
now we're checking if the type is vote and if the voter is the target
if (type == 'vote' && data.voter == TARGET) {
}
now we need to check the voting weight
console.log('@' + TARGET + ' Just voted now!');
if (data.weight < MINIMUM*100){
weight = MINIMUM*100;
}else{
weight = data.weight;
}
now all we need is to send the vote.
StreamVote(data.author, data.permlink, weight);
And here we have done, all you need to do is to run the script and wait for the voter and it will work perfectly!
results:
I hope I helped you and you learned something new, for more tutorials and helpful stuff you can follow me and upvote this posts, I will really appreciate it :)
Have a great day!
Leave [Hive Patched] Steem Bot - Curation Trail Bot to:
Read more #tutorial posts
Best Posts From TheLoneWolF
We have not curated any of lonelywolf's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From TheLoneWolF
- OFFICIAL: The Next Game From The Creator of Uncharted Series Is The Marvel Game
- A new trailer shows us what Battlefield 2042 will look like with RTX cards
- Double posted bug
- The creator of "Squid Game" has not received any bonus from Netflix
- From Now On Apple 🍏 Considers Itself A Gaming 🎮 Company
- Flowers💐, explosions💥, slow motion💨, going together?
- Why?! BlizzConline 2022 Conference Canceled🙄
- SplinterLands Season Rewards - 3 Accounts
- ArmA 3, RDR2 and more👊 | Summarize a week in sets - Special Halloween👻
- Microsoft defeats Apple 🍏 and becomes the company with the largest value in the world 💥