claim_reward.lua: Redeem your rewards with the power of LuasteemCreated with Sketch.

in #witness-category7 years ago (edited)

cash-1462856_640.png
Image source: Pixabay: Cash flow

I hate to hit the "REDEEM REWARDS" button, don't you? Let's do something to get rid of such boring task! Let the cash flow man!

First of all, claim_reward.lua is part of my lazy-steem project. If you are a witness take a look at my previous post: publish_feed.lua: Update your witness price feed with the power of Lua

There we go!

How to fetch the pending rewards balance

This is not dark magic, just a few lines of code and voila! claim_reward.lua relies on cli_wallet's JSON-RPC API. It requires two API calls: get_account and claim_reward_balance.

The output of get_account is huge, we only need this parameters:

{
  ...
  "reward_sbd_balance": "0.000 SBD",
  "reward_steem_balance": "0.000 STEEM",
  "reward_vesting_steem": "0.000 STEEM",
  ...
}

It has everything required for claim_reward_balance, everything else is really easy!

Running the script automagically every X minutes

Installation is pretty easy, all instructions are available in my previous article about publish_feed.lua, nothing has changed... yet!

And this is what you can put into your crontab:

# m h  dom mon dow   command
10  5  *   *   *     cd /path/to/lazy-steem/; ./claim_reward.lua dropahead http://localhost:8093 > /dev/null

Don't run away that fast!

If you liked this stuff then vote @dropahead for witness!

Talk is cheap, code is gold! You had better start a pull request if you want to say something about my precious code. Here: https://github.com/develCuy/lazy-steem

Happy hacking and keep steeming hard!

Sort:  

Congratulations @develcuy! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 65269.02
ETH 2653.11
USDT 1.00
SBD 2.84