SteemJS Help Needed --> 4 SBD + 4 SBD Rewards

in #steemjs6 years ago (edited)

I need some help with SteemJS. I'm developing some bots for Steem, but I'm not professional developer and I need some help.


1) 3 SBD Reward

I would like to get all posts with some tag that was created in last 24 hours. How?


32) 3 SBD Reward

I have this code:
It works fine, only when block contains no transactions it crashed. How can I check if block contains transactions and skip empty blocks?

//get steem.js -> npm install steem --save
var steem = require('steem');

//get transactions from head block
        steem.api.streamTransactions('head', function(err, result) {
          let txType = result.operations[0][0]
          let txData = result.operations[0][1]
          let includesVotes = checkBlockForVote(txType,txData)
          if (includesVotes) {
            console.log('POST FOUND: ', txData)
          }
        });
        function checkBlockForVote(txType,txData) {
          //check if voter is fbslo. If voter = fbslo, your account will vote same post.
          if( txData.voter == 'fbslo') {
            console.log('POST: ', txData)
            upvote(txData)
          }
        }
        function upvote(txData){
          console.log('Upvoting...',  )
          //You account name
          var voter = 'your-account';
          //Your account private posting key
          var wif = 'private-posting-key';
          var author = txData.author
          var permlink = txData.permlink
          //Change weight 100% vote = 10000; if you use txData.weight it will upvote with same voting weight as "followed" voter.
          var weight = txData.weight
          //Broadcast vote to blockchain
          steem.broadcast.vote(wif,voter,author,permlink,weight,console.log)
}

How to get reward?

Answer to my questions in comment bellow. You will also get 100% upvote :)


@fbslo


27496184_2012467288996553_1171355060_n.png
(Click on the button)

(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)


Please read my Witness Thread and support me by voting @fbslo for witness.

Sort:  
Loading...

For number 3 (where is number 2?), replacing the streamTransactions function with this, should fix the issues, by making Node.js ignore the errors. It also works when multiple operations are in one transaction:

steem.api.streamTransactions('head', function(err, result) {
  if (err) return;
  try {
    result.operations.forEach(function(op) {
      try {
        let txType = op[0]
        let txData = op[1]
        let includesVotes = checkBlockForVote(txType,txData)
        if (includesVotes) {
          console.log('POST FOUND: ', txData)
        }
      } catch (e) {}
    }, this);
  } catch (e) {}
});

Thank you very much :)

For number 3 (where is number 2?)

Those small typos are always the funniest.

keep going on you will be succed

sneaky-ninja-sword-xs.jpg
Sneaky Ninja Attack! You have just been defended with a 24.14% upvote!
I was summoned by @fbslo. I have done their bidding and now I will vanish...

woosh
A portion of the proceeds from your bid was used in support of youarehope and tarc.

Abuse Policy
Rules
How to use Sneaky Ninja
How it works
Victim of grumpycat?

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 60793.36
ETH 2909.65
USDT 1.00
SBD 3.64