<center></center> This tutorial is part of a series where different aspects of programming with `steem-python` are explained. Links to the other tutorials can be found in the curriculum section below. This part is a direct continuation on [Part 10: Use Urls To Retrieve Post Data And Construct A Dynamic Post With Steem-Python](https://steemit.com/utopian-io/@steempytutorials/part-10-use-urls-to-retrieve-post-data-and-construct-a-dynamic-post-with-steem-python). Where part 10 focused on constructing the post, this tutorial will post it to blockchain, upvote it for a variable amount and transfer SBD to each author in one transaction. --- #### What will I learn - How to build a list of transfers - Broadcast a list of transfers in one transaction #### Requirements - Python3.6 - `steem-python` #### Difficulty - Basic --- ### Tutorial #### Setup Start by going over the previous tutorial if you have not done so. After this download the files from [Gitub](https://github.com/amosbastian/steempy-tutorials/tree/master/part_11). Again there are 2 files. A text file in which the urls and post meta data is stored and the python script itself. In this example a post containing winners from a photography contest is constructed from urls, to each winners entry. This post is then submitted to the blockchain, and upvoted for a variable weight. In addition prize money is payed out to all winners in one grouped transaction on the blockchain. In order to submit the post additional data is required. This will be stored in `winners.txt` before the urls. ``` winners.txt #1 account #2 post title #3 tags #4 upvote weight #5 memo for transaction #6 total amount of SBD #7-7+n urls ``` Run the script by with the filename as the first argument `> python main.py winners.txt` #### How to build a list of transactions The Steem blockchain allows for transfers to be grouped together in one transaction. To make use of this, a list of each transfer has to be made. After which this list can be broadcasted at once. Each transfer consists of a sender `from`, receiver `to`, amount in `x.xxx SBD` or `x.xxx STEEM` and a `memo` which can contain a message. ``` transfers = [] for each winner: transfers.append( { 'from': account, 'to': author, 'amount': '{0:.3f} SBD'.format(amount), 'memo': memo }) ``` #### Broadcast a transaction The next block of code takes the list of transfers and constructs a single transaction. This is then broadcasted to the blockchain. `no_broadcast=False` can be set to `True` in case of testing. This allows you to test if everything is correct before sending SBD/STEEM. ``` tb = TransactionBuilder(no_broadcast=False) operation = [operations.Transfer(**x) for x in transfers] tb.appendOps(operation) tb.appendSigner(account, 'active') tb.sign() tx = tb.broadcast() ``` #### Submitting and upvoting the post The part which submits the post to the blockchain and upvotes it for a variable upvote weight has been taken from a [previous tutorial](https://steemit.com/utopian-io/@steempytutorials/part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python) ``` steem.post(title, body, account, permlink, None, None, None, None, tags, None, False) steem.vote('@{}/{}'.format(account, permlink), upvote_weight, account) ``` #### Running the code Running the code will now construct a post from urls and metadata. Submit it to the blockchain, upvote the post and transfer SBD to each winner. As can be seen in the photo below. The` transaction_id` for each SBD transfer is the same. Grouping transaction increases efficiency and reduces stress on the blockchain,.  To combine knowledge from the other tutorials. To schedule this post to be submitted at a certain time the following command can be used. ``` > echo 'python main.py winners.txt' | at 6:00 PM ``` #### Curriculum - [Part 0: How To Install Steem-python, The Official Steem Library For Python](https://utopian.io/utopian-io/@amosbastian/how-to-install-steem-python-the-official-steem-library-for-python) - [Part 1: How To Configure The Steempy CLI Wallet And Upvote An Article With Steem-Python](https://utopian.io/utopian-io/@steempytutorials/part-1-how-to-configure-the-steempy-cli-wallet-and-upvote-an-article-with-steem-python) - [Part 2: How To Stream And Filter The Blockchain Using Steem-Python](https://utopian.io/utopian-io/@steempytutorials/part-2-how-to-stream-and-filter-the-blockchain-using-steem-python) - [Part 3: Creating A Dynamic Autovoter That Runs 24/7](https://steemit.com/utopian-io/@steempytutorials/part-3-creating-a-dynamic-upvote-bot-that-runs-24-7-first-weekly-challenge-3-steem-prize-pool) - [Part 4: How To Follow A Voting Trail Using Steem-Python](https://utopian.io/utopian-io/@steempytutorials/part-4-how-to-follow-a-voting-trail-using-steem-python) - [Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots](https://utopian.io/utopian-io/@steempytutorials/part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots) - [Part 6: How To Automatically Reply To Mentions Using Steem-Python](https://utopian.io/utopian-io/@steempytutorials/part-6-how-to-automatically-reply-to-mentions-using-steem-python) - [Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python](https://utopian.io/utopian-io/@steempytutorials/part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python) - [Part 8: How To Create Your Own Upvote Bot Using Steem-Python](https://steemit.com/utopian-io/@steempytutorials/part-8-how-to-create-your-own-upvote-bot-using-steem-python) - [Part 9: How To Calculate A Post's Total Rewards Using Steem-Python](https://steemit.com/utopian-io/@steempytutorials/how-to-calculate-a-post-s-total-rewards-using-steem-python) - [Part 10: Use Urls To Retrieve Post Data And Construct A Dynamic Post With Steem-Python](https://steemit.com/utopian-io/@steempytutorials/part-10-use-urls-to-retrieve-post-data-and-construct-a-dynamic-post-with-steem-python) --- The code for this tutorial can be found on [GitHub](https://github.com/amosbastian/steempy-tutorials/tree/master/part_11)! This tutorial was written by @juliank in conjunction with @amosbastian. <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@steempytutorials/part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | steempytutorials | ||||||
---|---|---|---|---|---|---|---|
permlink | part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python | ||||||
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":["steempytutorials","amosbastian","juliank","amosbastian."],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png","https://steemit.com/utopian-io/@steempytutorials/part-10-use-urls-to-retrieve-post-data-and-construct-a-dynamic-post-with-steem-python","https://github.com/amosbastian/steempy-tutorials/tree/master/part_11","https://steemit.com/utopian-io/@steempytutorials/part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python","https://steemitimages.com/DQmbQASz9jdD3kKii9tmL7fn5wzPpZaLYvT2dofmKyGmMqV/Screenshot%202018-01-22%2018.30.54.png","https://utopian.io/utopian-io/@amosbastian/how-to-install-steem-python-the-official-steem-library-for-python","https://utopian.io/utopian-io/@steempytutorials/part-1-how-to-configure-the-steempy-cli-wallet-and-upvote-an-article-with-steem-python","https://utopian.io/utopian-io/@steempytutorials/part-2-how-to-stream-and-filter-the-blockchain-using-steem-python","https://steemit.com/utopian-io/@steempytutorials/part-3-creating-a-dynamic-upvote-bot-that-runs-24-7-first-weekly-challenge-3-steem-prize-pool","https://utopian.io/utopian-io/@steempytutorials/part-4-how-to-follow-a-voting-trail-using-steem-python","https://utopian.io/utopian-io/@steempytutorials/part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots","https://utopian.io/utopian-io/@steempytutorials/part-6-how-to-automatically-reply-to-mentions-using-steem-python","https://utopian.io/utopian-io/@steempytutorials/part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python","https://steemit.com/utopian-io/@steempytutorials/part-8-how-to-create-your-own-upvote-bot-using-steem-python","https://steemit.com/utopian-io/@steempytutorials/how-to-calculate-a-post-s-total-rewards-using-steem-python"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png","https://steemitimages.com/DQmbQASz9jdD3kKii9tmL7fn5wzPpZaLYvT2dofmKyGmMqV/Screenshot%202018-01-22%2018.30.54.png"],"moderator":{"account":"emrebeyler","time":"2018-01-22T20:01:36.808Z","reviewed":true,"pending":false,"flagged":false}} | ||||||
created | 2018-01-22 18:09:27 | ||||||
last_update | 2018-01-22 20:01:36 | ||||||
depth | 0 | ||||||
children | 7 | ||||||
last_payout | 2018-01-29 18:09:27 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 30.248 HBD | ||||||
curator_payout_value | 8.320 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 6,873 | ||||||
author_reputation | 31,094,047,689,691 | ||||||
root_title | "Part 11: How To Build A List Of Transfers And Broadcast These In One Transaction With Steem-Python" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 31,442,923 | ||||||
net_rshares | 4,328,258,232,345 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
fooblic | 0 | 18,663,786,429 | 100% | ||
adialam | 0 | 3,968,244,326 | 100% | ||
nicnas | 0 | 41,393,418,604 | 100% | ||
juliank | 0 | 407,698,665,716 | 30% | ||
cifer | 0 | 1,899,861,289 | 90% | ||
setianyareza | 0 | 583,272,900 | 100% | ||
utopian-io | 0 | 3,823,332,118,291 | 2.35% | ||
travoved | 0 | 5,338,111,114 | 100% | ||
apnigrich | 0 | 540,118,658 | 100% | ||
maxg | 0 | 1,367,168,407 | 100% | ||
amosbastian | 0 | 11,570,096,316 | 100% | ||
veenox | 0 | 178,386,463 | 100% | ||
oups | 0 | 955,090,777 | 100% | ||
fisherck | 0 | 1,205,277,966 | 100% | ||
mattockfs | 0 | 661,288,695 | 100% | ||
casberp | 0 | 334,679,246 | 100% | ||
amitsharma1990 | 0 | 604,911,383 | 100% | ||
steempytutorials | 0 | 2,514,395,319 | 100% | ||
ruby.eob | 0 | 552,855,502 | 100% | ||
johangericke | 0 | 1,446,882,747 | 100% | ||
amicat | 0 | 614,112,331 | 100% | ||
aripeng | 0 | 494,347,197 | 100% | ||
luj1 | 0 | 592,967,477 | 100% | ||
yz0rgc0rpb | 0 | 285,730,411 | 100% | ||
rubik66 | 0 | 605,256,026 | 100% | ||
muselew | 0 | 242,716,860 | 100% | ||
prodicode | 0 | 614,471,895 | 100% |
Very interesting. It would be good to learn all this.
author | apnigrich | ||||||
---|---|---|---|---|---|---|---|
permlink | re-steempytutorials-part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python-20180123t063150100z | ||||||
category | utopian-io | ||||||
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} | ||||||
created | 2018-01-23 06:31:51 | ||||||
last_update | 2018-01-23 06:31:51 | ||||||
depth | 1 | ||||||
children | 0 | ||||||
last_payout | 2018-01-30 06:31:51 | ||||||
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 | 53 | ||||||
author_reputation | 391,756,840,927,251 | ||||||
root_title | "Part 11: How To Build A List Of Transfers And Broadcast These In One Transaction With Steem-Python" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 31,574,166 | ||||||
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 | emrebeyler |
---|---|
permlink | re-steempytutorials-part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python-20180122t200146487z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-22 20:01:51 |
last_update | 2018-01-22 20:01:51 |
depth | 1 |
children | 1 |
last_payout | 2018-01-29 20:01:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.570 HBD |
curator_payout_value | 0.168 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 172 |
author_reputation | 448,535,049,068,622 |
root_title | "Part 11: How To Build A List Of Transfers And Broadcast These In One Transaction With Steem-Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 31,465,572 |
net_rshares | 66,536,767,344 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
juliank | 0 | 13,821,817,112 | 1% | ||
emrebeyler | 0 | 47,008,316,447 | 100% | ||
turbot | 0 | 5,706,633,785 | 100% |
Mucho gracias!
author | juliank |
---|---|
permlink | re-emrebeyler-re-steempytutorials-part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python-20180123t043422050z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-23 04:34:21 |
last_update | 2018-01-23 04:34:21 |
depth | 2 |
children | 0 |
last_payout | 2018-01-30 04:34:21 |
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 | 14 |
author_reputation | 117,823,071,447,502 |
root_title | "Part 11: How To Build A List Of Transfers And Broadcast These In One Transaction With Steem-Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 31,554,739 |
net_rshares | 0 |
Good tutorial!
author | muselew |
---|---|
permlink | re-steempytutorials-part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python-20180122t210557944z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-22 21:05:57 |
last_update | 2018-01-22 21:05:57 |
depth | 1 |
children | 0 |
last_payout | 2018-01-29 21:05: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 | 14 |
author_reputation | 2,392,465,159 |
root_title | "Part 11: How To Build A List Of Transfers And Broadcast These In One Transaction With Steem-Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 31,477,700 |
net_rshares | 0 |
very informative and educative post, I will try this tutorial
author | setianyareza |
---|---|
permlink | re-steempytutorials-part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python-20180122t181412556z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-22 18:14:15 |
last_update | 2018-01-22 18:14:15 |
depth | 1 |
children | 1 |
last_payout | 2018-01-29 18:14:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.018 HBD |
curator_payout_value | 0.006 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 61 |
author_reputation | 11,771,963,526 |
root_title | "Part 11: How To Build A List Of Transfers And Broadcast These In One Transaction With Steem-Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 31,443,860 |
net_rshares | 2,472,254,616 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
steempytutorials | 0 | 2,472,254,616 | 100% |
Have fun! If you have any questions feel free to ask
author | steempytutorials |
---|---|
permlink | re-setianyareza-re-steempytutorials-part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python-20180122t185635363z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-22 18:56:36 |
last_update | 2018-01-22 18:56:36 |
depth | 2 |
children | 0 |
last_payout | 2018-01-29 18:56:36 |
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 | 52 |
author_reputation | 31,094,047,689,691 |
root_title | "Part 11: How To Build A List Of Transfers And Broadcast These In One Transaction With Steem-Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 31,452,281 |
net_rshares | 0 |
### Hey @steempytutorials 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-steempytutorials-part-11-how-to-build-a-list-of-transfers-and-broadcast-these-in-one-transaction-with-steem-python-20180123t143803732z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-23 14:38:03 |
last_update | 2018-01-23 14:38:03 |
depth | 1 |
children | 0 |
last_payout | 2018-01-30 14:38:03 |
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,514 |
author_reputation | 152,955,367,999,756 |
root_title | "Part 11: How To Build A List Of Transfers And Broadcast These In One Transaction With Steem-Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 31,663,768 |
net_rshares | 0 |