Repository:
https://github.com/steemit/steem-js
What Will I Learn?
- You will learn how to make a bot
- You will learn how to power up using steemjs
- You will learn how to run timer
Requirements
- Node.JS
- SteemJS
Difficulty
- Basic
Curriculum
The Tutorial
Hello guys, welcome to the new tutorial.
today we will make an automatic bot that will powerup our STEEM
so first things first we want to install steem package,
go to your node project folder, open the terminal and install the steem package using - npm I steem --save
when you've done create js file, app.js
or index.js
the name does not make any differences.
now import the steem library
//Importing libraries/frameworks
let steem = require('steem');
create two variables, the first is acc
which will be the account name and the second wif
which will be our Private Active Key
and create a variable for the minimum SP to powerup.
let acc = "lonelywolf",
wif = "5Jxxxxxxxxxxxxxxxxxxxxxxxx";
let min_pwrup = 1;
now create a new function called accountPowerup
//creating the account powerup function
function accountPowerup(acc, wif){
console.log("Checking if your account has " + min_pwrup + " STEEM to power up!");
}
we need the acc and wif to make the powerup,
At the function, we sent console comment that says that we're checking if there is sp to powerup.
now get the account data
//getting the account data
steem.api.getAccounts([acc], function(err, res){
let account= res[0];
});
now we have the account data, we can check if the account has the SP to power up
//checking the steem balance with the minimum powerup var
if(account.balance.replace(' STEEM', '') >= min_pwrup){
}
so, we take the balance (which is the STEEM balance) and because we get a string (example: 1.587 STEEM) we "replace" the STEEM with empty space.
then we check if the amount is higher or equal to the minimum for powerup (min_pwrup
).
steem.broadcast.transferToVesting('5Jxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',acc,acc,account.balance, function(err, result) {
console.log(err, result);}
);
so we use the function transferToVesting
, we're using the wif key, we're sending it to our account (acc
) and using the whole balance of STEEM (account.balance
).
then we're sending console comment with the results/errors, but because the minimum is 1 so the chance for error is like 0%...
now all we need to do is at the bottom of the function add a timer for every 5 minutes or whatever you want.
setTimeout(function(){accountPowerup();}, 5*60*1000);
change 5 to any minute you want the function to run again.
now all you need to do is to start the function,
accountPowerup();
And because of the timer at the bottom, it will continue it every X minutes.
Hope you enjoyed and learned something new!
if you have any suggestions for the next tutorial, leave it on the comments!
Full Code Source: Here
Proof of Work Done
https://github.com/upmeboost-utopian