<center></center> This tutorial is part of a series, so make sure to read the other tutorials before starting this tutorial. Today we will learn how to automatically send the rewards from your other accounts (if you have them) to your main account using `steem-python`! --- #### What will I learn? - How to add multiple accounts to steempy - How to claim rewards on all your accounts - How to transfer these rewards to a main account #### Requirements - Python3.6 - steem-python #### Difficulty - Basic --- ### Tutorial #### Adding accounts First thing you want to do is add your account's active key and posting key (not relevant for this tutorial, but still). You can do this by typing ``` steempy addkey ``` Once you have typed this you will see the following ``` Private Key (wif) [Enter to quit]: ``` simply paste one of your keys and press enter until you have entered all of your keys. If you now type `steempy listaccounts` it should show all the accounts you have entered, for example for me it shows <center></center> #### Claiming rewards We already learned how to do this in the previous tutorial, so we will simply adapt the code so it works with multiple accounts. First of all we need to make a list with all our accounts and change the `claim_rewards()` function to take a username as argument. Once we have the list we can simply loop over it and call the `claim_rewards()` function in every iteration, like so ``` def claim_rewards(username): reward_SBD = steem.get_account(username)["reward_sbd_balance"] reward_SP = steem.get_account(username)["reward_vesting_steem"] print(f"{username} current rewards: {reward_SBD} and {reward_SP} POWER") if Amount(reward_SBD).amount + Amount(reward_SP).amount == 0: return else: steem.claim_reward_balance(account=username) print(f"Claim rewards: {reward_SBD} and {reward_SP} POWER") steem = Steem() accounts = ["sttest1", "sttest2"] for account in accounts: claim_rewards(account) ``` which gives the following output ``` sttest1 current rewards: 0.000 SBD and 0.000 STEEM POWER sttest2 current rewards: 0.000 SBD and 0.000 STEEM POWER ``` Unfortunately I don't have any rewards on these test accounts, but trust me, it actually works! #### Transferring SBD We can now claim all the rewards on all of our accounts, so the only thing left is to actually send the rewarded SBD to our main account. So instead of selling it on the market like we did in the previous tutorial, we are going to make a function called `transfer_sbd()` that does this for us. To do this we can use the `transfer()` function like so ``` def transfer_sbd(username): sbd_balance = Amount(steem.get_account(username)["sbd_balance"]).amount if not sbd_balance > 0: return print(f"Transferring {sbd_balance} to {main_account} from {username}") steem.transfer(main_account, sbd_balance, "SBD", account=username) main_account = "amosbastian" for account in accounts: claim_rewards(account) transfer_sbd(account) ``` where we make sure that we actually have some SBD to transfer. If you don't do this you might possibly get an error saying that you are trying to transfer a negative amount, and we don't want this! Anyway, the above code will output something similar to this ``` sttest1 current rewards: 0.000 SBD and 0.000 STEEM POWER Transferring 0.011 to amosbastian from sttest1 sttest2 current rewards: 0.000 SBD and 0.000 STEEM POWER Transferring 0.051 to amosbastian from sttest2 ``` Going to my wallet shows it worked fine! <center></center> If you want to schedule your program to run every day for example, you can use a `crontab` as we discussed in the first part of this tutorial series. Don't forget that if you want to do this you would have to add each account's passphrase to the crontab as an environment variable and then load this in your Python file! --- **Congratulations!** You can now automatically claim all the rewards on all of your accounts, then send these rewards to your main account where you can decide what to do with it! #### Curriculum - [Part 1: How to manage your wallet using steem-python - Automatically claim rewards](https://utopian.io/utopian-io/@amosbastian/how-to-manage-your-wallet-using-steem-python-1-claiming-rewards-automatically) - [Part 2: How to manage your wallet using steem-python - Automatically sell SBD on the market](https://utopian.io/utopian-io/@amosbastian/part-2-how-to-manage-your-wallet-using-steem-python-automatically-sell-sbd-on-the-market) --- The code for this tutorial can be found on my [GitHub](https://github.com/amosbastian/utopian-tutorials/blob/master/wallet-manager/account_manager.py)! <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@amosbastian/part-3-how-to-manage-your-wallet-using-steem-python-automatically-manage-your-accounts">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | amosbastian | ||||||
---|---|---|---|---|---|---|---|
permlink | part-3-how-to-manage-your-wallet-using-steem-python-automatically-manage-your-accounts | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":84843862,"name":"steem-python","full_name":"steemit/steem-python","html_url":"https://github.com/steemit/steem-python","fork":false,"owner":{"login":"steemit"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","steemdev","programming","python","tutorial"],"users":["amosbastian"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516285199/wg7nqlbywnrq2qdpdswb.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516285423/eyoudj8spdgzllx1vnhd.png","https://utopian.io/utopian-io/@amosbastian/how-to-manage-your-wallet-using-steem-python-1-claiming-rewards-automatically","https://utopian.io/utopian-io/@amosbastian/part-2-how-to-manage-your-wallet-using-steem-python-automatically-sell-sbd-on-the-market","https://github.com/amosbastian/utopian-tutorials/blob/master/wallet-manager/account_manager.py"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516285199/wg7nqlbywnrq2qdpdswb.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1516285423/eyoudj8spdgzllx1vnhd.png"],"moderator":{"account":"shreyasgune","time":"2018-01-18T17:07:50.480Z","reviewed":true,"pending":false,"flagged":false}} | ||||||
created | 2018-01-18 14:30:57 | ||||||
last_update | 2018-01-18 17:07:51 | ||||||
depth | 0 | ||||||
children | 6 | ||||||
last_payout | 2018-01-25 14:30:57 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 22.758 HBD | ||||||
curator_payout_value | 8.511 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 5,252 | ||||||
author_reputation | 174,473,586,900,705 | ||||||
root_title | "Part 3: How to manage your wallet using steem-python - Automatically manage your accounts" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 30,406,993 | ||||||
net_rshares | 4,683,081,842,482 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ubg | 0 | 855,431,574 | 1% | ||
steemitboard | 0 | 560,963,384 | 1% | ||
juliank | 0 | 68,751,650,760 | 5% | ||
p1c2u | 0 | 614,503,785 | 100% | ||
cifer | 0 | 5,319,925,229 | 60% | ||
utopian-io | 0 | 4,598,608,628,088 | 2.89% | ||
amosbastian | 0 | 2,136,120,310 | 100% | ||
casberp | 0 | 467,289,395 | 100% | ||
steempytutorials | 0 | 2,542,489,122 | 100% | ||
claraquarius | 0 | 2,078,846,657 | 5% | ||
darklifeform | 0 | 608,329,367 | 100% | ||
luj1 | 0 | 537,664,811 | 100% |
This is a great help to thr steemit peoplr , thank you so much dear friendππ
author | indrajeet |
---|---|
permlink | re-amosbastian-part-3-how-to-manage-your-wallet-using-steem-python-automatically-manage-your-accounts-20180118t143331370z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-18 14:33:33 |
last_update | 2018-01-18 14:33:33 |
depth | 1 |
children | 1 |
last_payout | 2018-01-25 14:33:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 76 |
author_reputation | 939,300,018,217 |
root_title | "Part 3: How to manage your wallet using steem-python - Automatically manage your accounts" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 30,407,538 |
net_rshares | 0 |
No problem!
author | amosbastian |
---|---|
permlink | re-indrajeet-re-amosbastian-part-3-how-to-manage-your-wallet-using-steem-python-automatically-manage-your-accounts-20180118t155358214z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-18 15:53:57 |
last_update | 2018-01-18 15:53:57 |
depth | 2 |
children | 0 |
last_payout | 2018-01-25 15:53:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 11 |
author_reputation | 174,473,586,900,705 |
root_title | "Part 3: How to manage your wallet using steem-python - Automatically manage your accounts" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 30,424,063 |
net_rshares | 0 |
Thank you for the contribution. It has been approved. You can contact us on [Discord](https://discord.gg/uTyJkNm). **[[utopian-moderator]](https://utopian.io/moderators)**
author | shreyasgune |
---|---|
permlink | re-amosbastian-part-3-how-to-manage-your-wallet-using-steem-python-automatically-manage-your-accounts-20180118t170758710z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-18 17:08:00 |
last_update | 2018-01-18 17:08:00 |
depth | 1 |
children | 1 |
last_payout | 2018-01-25 17:08:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.976 HBD |
curator_payout_value | 0.004 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 172 |
author_reputation | 4,924,803,411,962 |
root_title | "Part 3: How to manage your wallet using steem-python - Automatically manage your accounts" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 30,438,149 |
net_rshares | 119,091,589,302 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
shreyasgune | 0 | 116,688,061,823 | 100% | ||
amosbastian | 0 | 2,403,527,479 | 100% |
Thanks!
author | amosbastian |
---|---|
permlink | re-shreyasgune-re-amosbastian-part-3-how-to-manage-your-wallet-using-steem-python-automatically-manage-your-accounts-20180118t173541872z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-18 17:35:42 |
last_update | 2018-01-18 17:35:42 |
depth | 2 |
children | 0 |
last_payout | 2018-01-25 17:35:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 7 |
author_reputation | 174,473,586,900,705 |
root_title | "Part 3: How to manage your wallet using steem-python - Automatically manage your accounts" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 30,443,554 |
net_rshares | 0 |
Congratulations @amosbastian! You have completed some achievement on Steemit and have been rewarded with new badge(s) : [](http://steemitboard.com/@amosbastian) Award for the number of posts published [](http://steemitboard.com/@amosbastian) Award for the number of upvotes [](http://steemitboard.com/@amosbastian) Award for the number of comments [](http://steemitboard.com/@amosbastian) Award for the total payout received [](http://steemitboard.com/@amosbastian) Award for the number of upvotes received [](http://steemitboard.com/@amosbastian) You published 4 posts in one day [](http://steemitboard.com/@amosbastian) You published a post every day of the week Click on any badge to view your own Board of Honor on SteemitBoard. For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard) 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](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
author | steemitboard |
---|---|
permlink | steemitboard-notify-amosbastian-20180118t184311000z |
category | utopian-io |
json_metadata | {"image":["https://steemitboard.com/img/notifications.png"]} |
created | 2018-01-18 18:43:12 |
last_update | 2018-01-18 18:43:12 |
depth | 1 |
children | 0 |
last_payout | 2018-01-25 18:43:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,681 |
author_reputation | 38,975,615,169,260 |
root_title | "Part 3: How to manage your wallet using steem-python - Automatically manage your accounts" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 30,456,250 |
net_rshares | 0 |
### Hey @amosbastian I am @utopian-io. I have just upvoted you! #### Achievements - You have less than 500 followers. Just gave you a gift to help you succeed! - Seems like you contribute quite often. AMAZING! #### Suggestions - Contribute more often to get higher and higher rewards. I wish to see you often! - Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck! #### Get Noticed! - Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions! #### Community-Driven Witness! I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [](https://steemit.com/~witnesses) **Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
author | utopian-io |
---|---|
permlink | re-amosbastian-part-3-how-to-manage-your-wallet-using-steem-python-automatically-manage-your-accounts-20180119t191039555z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-19 19:10:39 |
last_update | 2018-01-19 19:10:39 |
depth | 1 |
children | 0 |
last_payout | 2018-01-26 19:10:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.016 HBD |
curator_payout_value | 0.005 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,509 |
author_reputation | 152,955,367,999,756 |
root_title | "Part 3: How to manage your wallet using steem-python - Automatically manage your accounts" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 30,690,358 |
net_rshares | 2,603,471,960 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
amosbastian | 0 | 2,603,471,960 | 100% |