How to claim(redeem) your rewards(Curation and Author rewards) automatically (Multiple accounts supported) by @chinadaily

in howto •  8 years ago  (edited)

Logo.PNG

About REDEEM REWARDS

Some people may notice that there's one new option in the wallet: REDEEM REWARDS (TRANSFER TO BALANCE) since the 0.18 HF.
redeem.PNG

Which means that we need to claim our rewards (curation rewards and author rewards) manually time to time, otherwise the rewards will be kept separate from balance.

This is a very annoying thing for OCD patients (such as me).
So I tried to use the program to process it automatically, finally I realized this goal.
Now, let me share it with you.

Install Python STEEM library

First, install the official STEEM library for Python
pip install -U steem
(Note: steem-python requires Python 3.5 or higher)

Find & Import posting private key

  1. Find out the posting (private) key for your steemit account
    You can get it at steemit.com Wallet-> Permissions->POSTING after login.
    (Click the SHOW PRIVATE KEY button to show private key)

  2. Add the private key to the local wallet :
    Run following command in terminal
    steempy addkey --unsafe-import-key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    ( Note: replace the xxxxxx with your posting private key )

  3. Find & Import posting private key for other users
    If you want to claim rewards for multiple accounts, you need to Find & Import posting private key for each account.
    Just repeat the Step 1 & Step 2 to do it.

The script

Here is the simple script to claim(redeem) your rewards.
You can save it as claim_rewards.py
Add execution permissions for it.
chmod u+x claim_rewards.py

#!/usr/bin/env python

import sys
import datetime
from steem import Steem

node = 'https://steemd.steemit.com'
password = 'yourwalletpasswd'
userlist = {'chinadaily', 'otheruser1', 'otheruser2', 'otheruser3'}

def reclaim(steem, user):
        try:
                user_info = steem.get_account(user)

                reward_sbd = float(user_info['reward_sbd_balance'].split(' ')[0])
                reward_steem= float(user_info['reward_steem_balance'].split(' ')[0])
                reward_vesting = float(user_info['reward_vesting_balance'].split(' ')[0])
                reward_sp = float(user_info['reward_vesting_steem'].split(' ')[0])

                if reward_sbd > 0 or reward_steem > 0 or reward_vesting > 0:
                        steem.claim_reward_balance(account = user)
                        print("{user} Claim rewards: {0} STEEM  {1} SBD {2} STEEM POWER".format(reward_steem, reward_sbd, reward_sp, user = user))

                else:
                        print("No rewards need to be claim")
        except:
                print("Error occured!")

def main(argv=None):
        steem=Steem(node = node)
        steem.wallet.unlock(pwd = password)
        print(datetime.datetime.now())
        for user in userlist:
                reclaim(steem, user)

if __name__ == "__main__":
        sys.exit(main())

Claim(redeem) your rewards by command

After config the right wallet password and the user list, Now you can claim(redeem) your rewards by run command manually.

In terminal, run ./claim_rewards.py
Here are the sample results I got

2017-05-12 19:07:30.634529
user1 Claim rewards: 0.0 STEEM 0.0 SBD 0.001 STEEM POWER
user2 Claim rewards: 0.0 STEEM 0.0 SBD 0.024 STEEM POWER
user3 Claim rewards: 0.0 STEEM 0.0 SBD 0.016 STEEM POWER
chinadaily Claim rewards: 0.0 STEEM 0.0 SBD 0.016 STEEM POWER

Run script automatically

To claim(redeem) your rewards automatically is very easy.
Add the script to cron, and it will be executed at your settings interval.
For example:
crontab -e

Add the following line and save:
0 0 * * * /path/claim_rewards.py >>log.txt 2>&1

Then the script will be executed at 00:00 every day.
You can find more details about crontab by man crontab

That's all, Thank you.
© @chinadaily

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:  
  ·  8 years ago (edited)

By setting the environment variable UNLOCK with your python-steem wallet password, you can avoid unlocking logic or pw handling in your code.

Thank you very much for your advice. :)

This is great. Unfortunately, I know nothing about python all the codes is talking about. Sorry I'm ignorant.

Can you add as many times as you like or would that be pointless?

I think I need to learn this python thing.

一起学习。

I love Python my current fav comp language easy to learn the basics too. Might even do a free course on it .

wow really good post!! thank you

You are welcome:)

Was wondering about this, and bingo... it's answered. Thanks.

any ideas? I get this error when installing steem

scrypt-1.2.0/libcperciva/crypto/crypto_aes.c:6:25: fatal error: openssl/aes.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

you need to install 'libssl-dev'

Thanks for making this guide. :)

Thank your work