A Twitter bot which issues its own currency

(Update: I’ve now taken my instance of the bot down, but the code should still work if you want to run your own.)

I spent some time this weekend putting together a proof-of-concept Twitter bot which issues its own “upvote” currency. You use it by tweeting something like the following:

@stellarjob +++@thegdb cool bot!

The bot then walks the user through linking their Stellar account and extending trust for its +++ currency. Once the trust has been granted, the bot issues a +++ credit. Each subsequent upvote results in another +++ being issued.

Because the credits are issued on Stellar, they can be seen on the account viewer, or even traded on Stellar’s distributed exchange.

 Code

You can grab the code for the bot from Github. Disclaimer: this code is definitely the quickest implementation that could possibly work; please don’t judge me for it :).

 Account linking

One interesting aspect of the project is how the bot links your Stellar account. It asks the user to extend trust for a unique number of +++.

When it sees a trust line for the appropriate amount, it then asks the user to confirm that it’s in fact their Stellar account. (Initially, I was tempted to try doing this without the confirmation — I wanted to see how long it could go without someone intercepting someone else’s +++. Unfortunately, before I’d even finished initial testing, one curious observer ended up completing the linking flow on behalf of one of the test subjects.)

 Stellar API calls

The set of Stellar API calls here are as follows:

The bot just polls the Stellar API for changes in trust, though in principle it could use the WebSocket API to get streaming updates.

 
172
Kudos
 
172
Kudos

Now read this

Setting up federated addresses with Stellar

Fun fact: the username you sign up with on Stellar’s hosted web client is actually a federated address rather than a username. That is, the username gdb is actually short for gdb@stellar.org. If you control a domain, you can set up... Continue →