Creating Bots with steem.js - Tutorial Series

in utopian-io •  10 months ago  (edited)

Repository

https://github.com/steemit/steem-js
https://github.com/code-with-sam/steem-js-bot-tutorials/

bots-with-steem-js.jpg

Creating Bots with steem.js

This set of tutorials is an updated version of a series I worked on at the start of 2018. Today I’m kicking off code-with-sam - my new initiative to bring back more tutorials to the blockchain. I’ve gone through the previous set of tutorials checked everything still works with the current api.steemit.com implementation.

These tutorials are probably the most useful content I've added to the chain. With the tutorials buried in old feeds and broken links from the previous Utopian.io version I wanted to bring the series back to life.

There is now a single store on Github for all of the tutorial code. Each tutorial is also now available on Codepen.io so can be quickly modified and played with.

Outline

These tutorials introduces the steem.js Javascript library. Capable of interacting with the STEEM blockchain via code. Steem.js is one of the first libraries developers of all skills levels encounter when researching the available resources.

These tutorials aim to introduce basic ideas of interfacing with the blockchain via code. Streaming transactions, inspecting transactions for a specific type (‘vote’, ‘comment’, ‘transfer’), submitting new transactions. Each tutorial aims to learn concepts with a real use-case by building a small project.

Difficulty

Beginner - Intermediate
This is a fairly friendly set of tutorials for those who have experimented with web development in any way in the past. If you are a complete beginner you should still be able to follow along. If you get stuck at any point leave a comment.

Requirements

  • A plain text editor (I use VS Code )
  • Your private posting key - This is found in your wallet on the permissions tab on steemit.com, click ‘show private key’ (remember to keep this safe - treat is as your password).
  • Some tutorials use Node.js
  • Enthusiasm for the STEEM Blockchain 🙌

#1 Auto Upvote Bot - Upvote posts from a set of users

| Tutorial
| Github - Code
| Codepen Example

#2 Curation Bot - Copy the upvotes of a selected user
| Tutorial
| Github - Code
| Codepen Example

#3 Auto follow bot - Copy who a selected user follows
| Tutorial
| Github - Code
| Codepen Example

#4 Paid upvote bot - Upvote a user in proportion to receiving SBD
| Tutorial
| Github - Code
| Codepen Example

#5 @ Mention Notifier bot - Receive an email when @mentioned
| Tutorial
| Github - Code
| Codepen Example

formcarry.com is now a viable alternative to using formspree as the orginal tutorial mentions. You can create a free form at Formcarry and set you email to be notified. After creating a form you’ll see 🗝 Your form endpoint which you can use as the url in the Ajax function.

#6 Auto Reward Claimer bot - Check and claim rewards
| Tutorial
| Github - Code
| Codepen Example

#7 Bots In The Background - Using Node.js and scheduling code
| Tutorial
| Github - Code
| Repl.it Example

#8 Stats Responder - Reply with message when @mentioned
| Tutorial
| Github - Code
| CodePen Example

#9 Contest Bot - Storing JSON & checking hastags
| Tutorial
| Github - Code
| *Example - this project requires file system access and therefore is not easily able to live on Codepen or repl :(

#10 ReBlogged List - Checking all transactions for specific data
| Tutorial
| Github - Code
| Codepen - Example
| Codepen - Optimised alternative

#11 Zeit Now - Running your Steem.js Bot 24/7 on a Server
| Tutorial
| Github - Code

While this tutorial still works and is a great starter to node.js, Zeit Now it is not recommend for production code. As of November 8th 2018 Zeit moved to version 2 and the platform has changed significantly. You can specifically set version 1 while it is still supported.

{
    "env": {
        "BOT_POSTING_KEY": "@bot-11-posting-key"
    },
    "version": 1
}

#12 User Wallet History with Steem.js
| Tutorial
| Github
| Codepen

I hope you find this set of tutorials useful. I will be going over each of the tutorials to create a new version that uses DSteem instead of steem.js. Over the past year DSteem has grown in popularity to become the defacto Javascript library for interacting with the blockchain. DSteem outperforms steem.js in benchmarks, is feature rich and maintained to a higher standard than steem.js.

If you feel any of these tutorials need further updating you can submit a PR on Github or comment here.

If you have questions or ideas on anything related to these tutorials or steem.js please reach out.

Github

@codewithsam is my new page for tutorials
Github - code-with-sam x sambillingham
https://github.com/code-with-sam/steem-js-bot-tutorials/

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:  

Hello,

These are some great news. First of all, collecting all your past tutorials and putting them in one place was a great move. I believe that your followers and all readers who look for tutorials for steem.js will be satisfied that they can find them all in here. Moreover, putting the codes onto codepen was a good decision also.

Let me tell you that despite tagging this post as a tutorial, we rather see it as a more general piece of content, thus evaluating it as a blog post this time.

All in all, the text is good and serves its purpose to announce your intentions of redoing the tutorials in DSteem. However, while writing a post, you overlooked a few of things that I will point out here.

  • The format of some titles is broken because you left a space in front of the asterisks.
  • Sometimes you forgot a character in a word or did not put a space to separate two words. These are tiny issues, but when you write your other posts, try to eliminate as many of these details as possible.

I suppose we have something to look forward to in Utopian. Keep up the good work.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks @espoem I appreciate you taking the time to look through the post.

You're right I probably should have tagged this as a blogpost instead of tutorials. I was wondering how best to submit it to Utopian or if it was really acceptable. I knew I wanted this to exist so I just went ahead and posted it.

It was pretty late by the time I finally got all of this together! Excuse the mistakes. It took a long time, maybe 5 hours or more 😅sounds ridiculous typing that. I'm glad I've finally pulled everything together now.

Looking forward to bringing more tutorials back to Utopian. :)

No worries about the tags. We communicate within the team in similar cases although the reviewers can see the contributions categorized by the tags.

I understand that it must have taken lots of time to prepare the materials and write the post. Yet, if you were able to edit the post and delete the extra spaces in the tutorials' titles, it would look better as the extra characters would not be displayed. It will not increase the score, but I believe that it will improve the readability of the post even though those highlighted issues are not critical.

Thanks again, I've updated :)

Thank you for your review, @espoem! Keep up the good work!

Yes! This is excellent! Thanks Sam!

As mentioned previously, I still find myself scrolling back through your blog posts to find little clues to the various questions I have. As you're aware, I have created dicebots that a number of games have used, all created following your tutorials and hosted on Zeit (I did figure out that instance problem we were having a while back).

I'd highly recommend these tutorials to anyone interested in coding. The first couple you can run just in your browser which is amazingly simple and instantly gratifying.

I'm sure a ton of work went into this, and I love this account's profile pic. Thanks again!

It's awesome to know you found these tutorials useful. It's easy to think you are posting into the abyss sometimes. It took way longer than I expected to bring all of this back together 😅. Hopefully It can live a little longer now. I'm keen to dig into DSteem and share the differences.

Would be keen to hear about how you fixed the scaling/instance issue I still struggle with it.

Zeit V2 has done away with instances and scaling all together now and is mostly auto. Not sure V2 will work for this type of scripts anymore. I'm going to look into the best alternative.

Glad you like the codewithsam icon 👨🏼‍💻 🙌

To be honest, I don't seem to be using V2 at the moment... I only just noticed the info on it now.

Soooooo…. stupidly it looks like I didn't note down the exact command I used... which is annoying because I spent ages systematically trying every possible variation.

You don't happen to know a way to see the scale of a deployment do you?

I think it was something like

now scale https://blah.now.sh 1 sfo1

Something like that... I did notice that as I was trying a lot of things, it would automatically scale to two instances, and I'd have to put it to 0 instances and start over... I couldn't just try another now scale command over the top.

Haha, not only did I find them useful, but maybe like 100 people have used my dicebots in various games on the platform. Maybe more people honestly...

Amazing man! That could help automate some of the actions here on Steem.
Thanks for sharing!
Cheers

For sure! Give it a try and let me know if I can help you out.

Congratulations @codewithsam! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Saint Nicholas challenge for good boys and girls

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @codewithsam! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 100 upvotes. Your next target is to reach 250 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Saint Nicholas challenge for good boys and girls

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @codewithsam! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made your First Vote

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Saint Nicholas challenge for good boys and girls

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @codewithsam!
Your post was mentioned in the Steem Hit Parade for newcomers in the following category:

  • Pending payout - Ranked 3 with $ 10,54

I also upvoted your post to increase its reward
If you like my work to promote newcomers and give them more visibility on the Steem blockchain, consider to vote for my witness!

Hey, @codewithsam!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Hi @codewithsam,

Thank you so much for such a well rounded article and tutorials!

I am looking at building a DAPP for Steemit / bots to do my bidding...Whahahha

Do you offer services in terms of this type of development and can you get me some help in terms of setting up a team that will see this project through with integrity, love and accountability to the community?

Thank you