create account

Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots by steempytutorials

View this thread on: hive.blogpeakd.comecency.com
· @steempytutorials · (edited)
$38.98
Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots
<center>![steem-python.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png)</center>

This tutorial is part of a series where we explain different aspects of programming with `steem-python`. Links to the other tutorials can be found below. You will learn how `steem-python` can be used to post an article from file directly to the Steem blockchain as well as built and broadcast a transaction to purchase an upvote for the article posterd.

---

#### What will I learn

- What submitting a post looks like in `steem-python`
- Creating an unique permlink
- How a transaction is built
- How to broadcast a transaction

#### Requirements

- Python 3.6
- `steem-python`

#### Difficulty

- Basic

---

### Tutorial

#### Set up
Start by downloading both files from [github](https://github.com/amosbastian/steempy-tutorials/tree/master/part_5). The `post.txt` is used to store the post we want to submit and the title and tags we would like to use. The first line is used for the title and the second line is for the tags, separated by a whitespace. The rest of the file is the body of the post.

```
#1 Title 'Test' Buy Upvote
#2 blog test steemdev
#3 <center>
#4 Test buying upvote from minnowbooster
#5 </center>
```
In `scheduler.py` you will have to set the author, the upvote bot you want to use and what amount in SBD you want to buy upvotes for.

```
author = 'sttest2'
upvote_bot = 'minnowbooster'
amount = 0.05
```
<br>
#### What does submitting a post look like?
Submitting a post with `steem-python` requires several variables. Most of them are  optional. We will be using the title, body, author, permlink and self_vote.

```
def post(self,
             title,
             body,
             author,
             permlink=None,
             reply_identifier=None,
             json_metadata=None,
             comment_options=None,
             community=None,
             tags=None,
             beneficiaries=None,
             self_vote=False):
```
Calling the post function to submit the post then looks like:

`steem.post(title, body, author, permlink, None, None, None, None, tags, None, True)`

##### Permlink
The permlink is an unique identifier for each post, which is linked to the author of the post. Leaving this blank `steem-python` will automatically assign a permlink based on the title. However, the permlink is needed to buy an upvote, therefor a permlink needs be to created from the title. To make sure the permlink created is unique and valid all characters except for letters and numbers  will be removed, as well as capitals. A random number and a timestamp will be added as well. 

```
permlink_title = ''.join(e for e in title if e.isalnum()).lower()
permlink = "{}-%s%s".format(permlink_title) % (time.strftime("%Y%m%d%H%M%S"), random.randrange(0,9999,1))
```

#### How is a transaction built?
A transaction is built up by a sender, receiver, amount in SBD/STEEM and an optional memo in a dict. For sender the author  will b used and the receiver will be the upvote_bot. SBD will be used and the memo will be full url to the article, including permlink and author.
```
transfers =[{
        'from': author,
        'to': upvote_bot,
        'amount': 'amount SBD',
        'memo': 'full url to post'
    }]
```

The full url to the post can be created with the permlink and author as follows:
```
'https://steemit.com/@{}/{}'.format(author, permlink)
```

The next code is then used to sign and broadcast the transaction

```
    tb = Transactionbuilter()
    operation = [operations.Transfer(**x) for x in transfers]
    tb.appendOps(operation)
    tb.appendSigner(author, 'active')
    tb.sign()
    tx = tb.broadcast()
```

**Note**: `transfers` is a list with transactions. Each transaction is put in a dict. This allows for multiple transactions to be broadcasted at once. Like for example if you wish to purchase multiple upvotes from several upvote bots.

#### Running the code
Now that you have configured the code to your own liking you can test it for yourself.

> python scheduler.py
Submitted post
Buying vote succes

![Screenshot 2018-01-16 17.09.40.png](https://steemitimages.com/DQmdYb9K2i3jsgb7Cd1GZZ3M7FAGmVN1MEuGebzvaytQYXe/Screenshot%202018-01-16%2017.09.40.png)


#### 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://steemit.com/utopian-io/@steempytutorials/part-2-how-to-stream-and-filter-the-blockchain-using-steem-python)
- [Part 3: Creating A Dynamic Upvote Bot 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://steemit.com/utopian-io/@steempytutorials/part-4-how-to-follow-a-voting-trail-using-steem-python)

#### Credits
This tutorial was written by @juliank in conjunction with @amosbastian

---

The code for this tutorial can be found on [GitHub](https://github.com/amosbastian/steempy-tutorials/tree/master/part_5)!

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@steempytutorials/part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorsteempytutorials
permlinkpart-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots
categoryutopian-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":["juliank","amosbastian"],"links":["https://github.com/amosbastian/steempy-tutorials/tree/master/part_5","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://steemit.com/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://steemit.com/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"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png","https://steemitimages.com/DQmdYb9K2i3jsgb7Cd1GZZ3M7FAGmVN1MEuGebzvaytQYXe/Screenshot%202018-01-16%2017.09.40.png"],"moderator":{"account":"jestemkioskiem","time":"2018-01-16T21:05:41.098Z","reviewed":true,"pending":false,"flagged":false}}
created2018-01-16 17:07:57
last_update2018-01-16 23:00:09
depth0
children8
last_payout2018-01-23 17:07:57
cashout_time1969-12-31 23:59:59
total_payout_value29.418 HBD
curator_payout_value9.559 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,707
author_reputation31,094,047,689,691
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id29,985,078
net_rshares5,304,454,036,531
author_curate_reward""
vote details (25)
@azizulhassan ·
iss it right
properties (22)
authorazizulhassan
permlinkre-steempytutorials-part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots-20180117t194826458z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-17 19:48:27
last_update2018-01-17 19:48:27
depth1
children0
last_payout2018-01-24 19:48:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length12
author_reputation858,685,273,941
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,243,999
net_rshares0
@jestemkioskiem ·
$0.37
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)**
👍  
properties (23)
authorjestemkioskiem
permlinkre-steempytutorials-part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots-20180116t205817623z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-16 20:58:21
last_update2018-01-16 20:58:21
depth1
children1
last_payout2018-01-23 20:58:21
cashout_time1969-12-31 23:59:59
total_payout_value0.277 HBD
curator_payout_value0.089 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length172
author_reputation41,292,066,961,817
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,024,687
net_rshares41,217,683,489
author_curate_reward""
vote details (1)
@juliank ·
Much appreciated!
👍  
properties (23)
authorjuliank
permlinkre-jestemkioskiem-re-steempytutorials-part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots-20180116t220724792z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-16 22:07:24
last_update2018-01-16 22:07:24
depth2
children0
last_payout2018-01-23 22:07:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length17
author_reputation117,823,071,447,502
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,035,183
net_rshares240,724,088
author_curate_reward""
vote details (1)
@jestemkioskiem ·
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)**
properties (22)
authorjestemkioskiem
permlinkre-steempytutorials-part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots-20180116t210546973z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-16 21:05:48
last_update2018-01-16 21:05:48
depth1
children0
last_payout2018-01-23 21:05:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length172
author_reputation41,292,066,961,817
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,025,878
net_rshares0
@jza ·
This is a great article, I wonder if its still current with the latest Steem hard forks. But definetly a great post.
properties (22)
authorjza
permlinkre-steempytutorials-part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots-20180914t213539236z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-09-14 21:35:42
last_update2018-09-14 21:35:42
depth1
children0
last_payout2018-09-21 21:35:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length116
author_reputation38,025,632,925,704
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id71,309,555
net_rshares0
@sorn1992 ·
Good post, I am a photographer, it passes for my blog and sees my content, I hope that it should be of your taste :D greetings
properties (22)
authorsorn1992
permlinkre-steempytutorials-part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots-20180117t154330882z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-17 15:40:36
last_update2018-01-17 15:40:36
depth1
children0
last_payout2018-01-24 15:40:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length126
author_reputation276,397,313,897
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,198,448
net_rshares0
@utopian-io ·
### 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>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](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**
properties (22)
authorutopian-io
permlinkre-steempytutorials-part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots-20180117t134406525z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-17 13:44:06
last_update2018-01-17 13:44:06
depth1
children0
last_payout2018-01-24 13:44:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,514
author_reputation152,955,367,999,756
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,174,706
net_rshares0
@yehey ·
@steempytutorials,

How will I specify the POSTING Key of the steem user? To auto post the article on a certain schedule.
properties (22)
authoryehey
permlinkre-steempytutorials-part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots-20180531t221150264z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["steempytutorials"],"app":"steemit/0.1"}
created2018-05-31 22:11:51
last_update2018-05-31 22:11:51
depth1
children0
last_payout2018-06-07 22:11:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length121
author_reputation22,184,787,552,504
root_title"Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id58,664,329
net_rshares0