Intro

I really like Byteball and I think it is a gem in the crypto world. A small but very honest and active team and community, no ICO and a good attitude of the core dev team with a clear focus on building. Overall it is one of the rare project teams in crypto that are underpromising and overdelivering, which I really like.

So far I used Byteball from time to time to play around and I have also built some stuff at hackathons and at work with some colleagues and friends (but not in the role of a developer – I rarely program unfortunately, so I am not a good developer).

I always wanted to learn more and program my own stuff on Byteball, but time is quite limited. At the moment I am on a 3 week honeymoon vacation and I get some time of from my wife sometimes (I have the best wife in the world :)) that I use to learn something new – developing stuff on Byteball :)

It is a nice coincidence that also the Byteball Bot Wars are happening right now, so I decided to participate there and build my own bot.

Here is the link to the repo for it.





About the bot

I needed some time to come up with a good usecase idea that solves a real world problem. When thinking about some of the problems and hurdles of past and ongoing projects, it came to my mind that we could solve something we had as an idea for a hobby project I am running with some friends in our spare time – www.ErrorFareAlerts.com.

Error Fare Alerts basically curates content – we find very cheap travel deals and error fares (price errors) by scraping some websites and link to them or write blog posts on deals we find on our own. Also we filter and publish only the best ones.

The idea we had some time ago was to monetize this project by creating a premium subscription (besides using affiliate deals) to cover the running cost of the business (it is a hobby project, so we don´t want to cover the cost of our time, but our target is to cover the running cost of the GmbH, the server cost and so on).

So the idea for this bot is to create a paid subscription service, with the benefit, that subscribers of the premium service get deals earlier than subscribers from the free tier. And besides that they will also get some premium deals, free subscribers will not get.





This is how the bot will work:

A user can add the bot via the pairing code into the contacts of his Byteball wallet.

The Bot has a deposit and withdrawal functionality, that means a user can deposit Bytes and withdraw them.

Deposited Bytes are used to pay for every deal (0,03 Euro per deal). The subscriber will get the link to every deal via the Chat interface of the bot.

If there is not enough money deposited, the user will get a notification in the wallet that he missed a deal, because he had not enough funds deposited. If there are enough funds the user gets a notification and the link to the deal is posted directly in the Chat window.

ErrorFareAlerts is running on a Cloud Platform and every new deal is getting posted into a database. So we can subscribe to a notification service that gets every new entry that is made into this database.

Outlook – similar usecases

I think the bot can finally also serve as a template for similar content curation businesses and newsletters, that want to monetize their content. Also you could monetize API calls with the same structure.





What has been done so far

I mainly used the little time to read the developer resources, which are very well written!

Thanks to Tarmo and Evgenii!

Then I got my first ping-pong bot running locally via the newcomer tutorial.

I checked out the sourcecode of a lot of other bots in the byteball github.

And as I played around with the dice-bot https://github.com/xJeneKx/dicebot in the past. It came to my mind, that it also has a deposit and withdraw functionality.

The code I have so far is mainly consisting of the bot-example from the newcomer tutorial and the dice-bot. I deleted the parts that are not needed and already changed some text to represent the bot I am building. Also I changed the database structure a little bit.

What the bot does so far:

The bot is working locally and is sending a greeting message after pairing.

It has some menu points:

About, How to buy Bytes, Deposit, Withdraw, Referral program and Terms of Use the user can click on.

And it is showing the current balance of the user.





About

Gives again the text of the welcome message. Working functionality.





How to buy Bytes

Text instruction on how to get Bytes. Working functionality.





Deposit

Here you can Deposit money that is consumed for new deals. Working functionality.





When clicking on "1mb":





Clicking on the Payment request opens the prefilled send window:





After clicking on „Send“ it confirms the payment and waits until it is stable.





Withdraw

Here you can withdraw the money again, if you don´t want to use the premium subscription service anymore or pause it, as you, for example, already booked enough deals for the rest of the year :)

Working functionality.





When clicking Yes:





Transaction history proves that it worked:





Referral Program

This is not yet implemented, but it will also mainly use the dice-bot functionality, which also has a referral program. If you refer new users to the premium subscription that spend money on it, you get 20% of that money.



Terms of use

Legal stuff to exclude liabilities, borrowed from http://freebe.byte-ball.com/ :)





Learnings so far

#1

First of all I have learned, that developing in Byteball is very easy thanks to the great ressources they provide e.g. at https://developer.byteball.org/ - it is very easy even if you are not a programming expert, like me.

#2

Getting the bot-example running on the test-net was a little challenge, as I have to manually change some stuff when running on windows. This was not stated in the developer ressources but Evgenii helped me out very quickly on https://t.me/devbyteball. Here is the solution, if you run into the same issue:





So in the node_modules/byteballcore/constants.js „Set version“ hast o be changed from „1.0“ to „1.0t“ and „alt“ from „1“ to „2“. In the conf.js „hub“ had to be changed from „byteball.org/bb“ to „byteball.org/bb-test“. Finally, the pairing code that is printed needs to be changed in an way, that you replace the „*“ by any number (pairing secret).

#3

I got the bot-example https://developer.byteball.org/tutorials-for-newcomers/ping-pong-paymets running, but after that I decided to switch to the live net for development. Confirmations are faster there and the fees for a transaction are ~0,00002 EUR only, so it is easier and cost you next to nothing when you develop on the live net.

#4

Combining the bot-example with the dice-bot code I faced some challenges with finding the database. I wasted quite some hours to find where the database is located. I googled a lot and searched in the project folder. The solution at the end was very simple, as the database location is getting printed in the cmd after you start with „node start.js“.





Having never worked with sqlite I also learned how to make changes in the database like inserting new tables. There are plenty of guides you can easily find on the internet like this one. Working with sqlite seems to be quite easy.

#5

Finally when I had everything running I decided to publish it on github. Learning here: I should have done that from the beginning, so that all changes and commit messages and forks are tracked. On github I created a new project and connected it with sourcetree for management. It would have been easier and would have cost me less time when I directly would have worked on a fork of the bot-example and dice-bot with git.





What´s next

Create dummy DB and setup a stream and push functionality so that I get a notification for every new Error Fare into the Bot for testing. Change the code of the bot so it pushes the notification to the chat every time a new error fare comes. Change the code of the bot so that it only pushes deals into the chat if the balance of the user is enough and reduces the balance after each sent link. Change from local environment to hosting the bot on a VM. Add referral program. Dynamic pricing (at the moment price is hard coded, maybe I will change that, so that it is stable in EUR and dynamically generates the needed Bytes). Publish in Byteball Bot Store :)

If I want to survive my honeymoon vacation I don´t think I get it all done during the timeframe of the Great Byteball Bot Wars, but I hope to get point 1 to point 2 done until the Bot wars are over at least. If you don´t hear back from me I spent too much time on building this bot and my wife killed me :D





Ressources

https://developer.byteball.org/

https://github.com/xJeneKx/dicebot

https://github.com/byteball

http://freebe.byte-ball.com/ (Terms of Use adaption)

Others as linked in this article

Git of this bot:

https://github.com/AnGrYxx/efa-bot





Thanks to