build bot multitransfer steemjs

Words
346
Reading
2 min
Listen
Play
8y

Repository

e.g. https://github.com/steemit/steem-js

What Will I Learn?

You will learn how to create a multi-bot that will make multiple transactions to different users

Requirements

Node.JS
Steem Package Install: npm install steem --save
key active of your account

Difficulty

easy

Creation of the bot

first of all we keep the name of our account and the active key which is found in the permissions of our wallet. Besides this we need to import the steem library for steemjs


'use strict'
var steem = require('steem');
var passactive='active key'
var cuentaprin='account name'

then save in an array the users who are going to make the transaction without including the @ in addition to this it is necessary to include the amount to transfer either in steem dollar or in steem if it is in steem is defined the amount and is given the indications that it will be steem if it is in steem dollar is given the value to transfer to each user and the indicator is SBD, Finally the memo is written that will be sent to each of the users


var user=[
"usuario1",
"usuario2",
"usuario3"
]
var quantity=0.3 SBD
var memo=transfer memo for all users

once all this data is finished, it is placed in a for-cash cycle to perform the transactions to each of the users using the apem of steemjs


for(var i=0;i<=(user.length-1);i++){
steem.broadcast.transfer(passactive, cuentaprin, user[i], quantity, memo, function(err, result) {
if(err) throw err
console.log(completed transaction)
});
}

then just run the code in node js so that it sends all the users their amount with the indicated memo. Remember that the code will vote error if you do not have the amount for necessary to perform the transactions to any of the users

final code


'use strict'
var steem = require('steem');
var passactive='pass active'
var cuentaprin='account namber'
var user=[
"usuario1",
"usuairo2",
]
var quantity='0.002 SBD'
var memo='transfer memo for all users'
steem.api.setOptions({ url: 'wss://rpc.buildteam.io' });
for(var i=0;i<=(user.length-1);i++){
steem.broadcast.transfer(passactive, cuentaprin, user[i], quantity, memo, function(err, result) {
if(err) throw err
console.log('transaction completed')
});
}

tests of bot functionality

You can verify in the transactions of my account in which I made with the bot two transfers of 0.002 SBD to the accounts giveaway.tera and infinitycycle

this project will be uploaded to github in the direction
https://github.com/ederaleng/multitransfer