Steem Bots - Auto Power Up

in utopian-io •  5 years ago  (edited)

image.png


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

Have a great day!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you for your contribution @lonelywolf.
After reviewing your tutorial we suggest the following points listed below:

  • Your tutorial is quite short for a good tutorial. We recommend you aim for capturing at least 2-3 concepts.

  • In the next tutorial, be more careful with writing and improve the structure of the contribution.

  • It would be interesting to have at the end of the tutorial a GIF showing the results in the terminal.

Looking forward to your upcoming tutorials.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your review, @portugalcoin! Keep up the good work!

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by TheOver from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Hi, @lonelywolf!

You just got a 0.17% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Hey, @lonelywolf!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!