When someone writes a great post on Reddit that goes viral and is widely shared, the party that benefits most is Reddit itself. Realizing this and wanting to give back to the community responsible for its success, Reddit toyed with the idea of giving shares of the company to users in the form of a cryptocurrency. This plan was later put on indefinite hold.
Steem is the embodiment of what Reddit wanted to achieve -- a blockchain-based, social news platform where posters and upvoters, i.e. "curators", are rewarded directly with cryptocurrency (actually three currencies: STEEM, Steem Power, and Steem Dollars). I was first exposed to Steem via Steemit, a website built on top of the Steem blockchain. My first thought after learning about Steemit and reading the white paper was "wouldn't it be neat if I could write a bot that would 'curate', upvote posts for me, and make me rich overnight?" Of course, it wasn't that easy, but at least no one can say I didn't try to get rich quick.
This is a guide to creating a simple bot that will periodically upvote a random post. Specifically, the bot will work like this (numbers are configurable):
Our bot will be built using GitHub, Heroku, and @xeroc's excellent Steem library, steem-piston. We'll build this in two steps:
The first step is to create an account on Heroku. Dynos are the Heroku term for virtual machine instances. You initially start with 550 free dyno hours. If you add a credit card number, you get an additional 450 free hours and the ability to use free add-ons. We will be using the free Scheduler add-on to make our bot run every 10 minutes, so add your credit card number now.
If you didn't add your credit card during registration, you can do so after you login:
Click your avatar in the upper right-hand corner --> Account settings --> Billing
Next you need an account on the Steem blockchain (this costs a fee). The easiest way to do this is to register an account on Steemit, a website that runs on top of Steem to display its contents (Steemit will pay the fee). To help combat account creation abuse, Steemit recently switched from a Facebook/Reddit registration process to an email + SMS process.
After you finish registering, log into your Steemit account and grab your private Posting key. You can find this by going to the URL below and clicking Show Private Key next to Posting. Our bot will need this key to vote on our behalf.
https://steemit.com/@ReplaceWithYourSteemHandle/permissions
Git is a version control system for tracking changes to files and coordinating work on those files among multiple people. GitHub is a popular web-based service that hosts Git repositories. We will use GitHub to store our code in a repository and then point Heroku to that repository.
What is a fork?
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project. https://help.github.com/articles/fork-a-repo/
In this case, you'll fork my repository by clicking the link below, logging into your GitHub account, and clicking the Fork button in the upper right-hand corner.
https://github.com/charlesjlee/steemBot
Now we're ready to create our Heroku project:
steemBot
repository you just forkedLet's set some custom values:
Click Reveal Config Vars. There are 5 config vars we need to enter:
key | example value | comment |
---|---|---|
numPostsToConsider | 20 | Number of recent posts to consider |
percentChanceToPost | 5 | Percent chance that script will run. Must be between 0 and 100 |
steemAccountName | 'mySteemName' | Your Steem account name wrapped in single quotes |
steemPostingKey | 'myPrivatePostingKey' | Your Private Posting Key that you saved when creating your SteemIt account, wrapped in single quotes |
voteWeight | 100 | How much voting power to use per upvote. Note that voting power decreases after every vote. Must be between 0 and 100 |
Finally we schedule our bot using the free Heroku Scheduler Add-on:
That's it! Now our bot is running every 10 minutes and has a percentChanceToPost
chance to activate. Every time the bot activates, it will choose a random post from the most recent numPostsToConsider
and upvote it with weight voteWeight
. You can see the run logs of your bot by going to:
More (to the right of Open app, in the upper right corner) --> View logs
You can see your handiwork being written to the Steem block chain using this block chain explorer: https://steemd.com/@ReplaceWithYourSteemHandle