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.
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 :).
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:
- Retrieve the set of trustlines for the stellarjob account via
- Submitting a TrustSet for the stellarjob account (initiated by the end-user)
- Send the actual
+++credit by submitting a Payment
- Reverse-resolve the detected account to a username
The bot just polls the Stellar API for changes in trust, though in principle it could use the WebSocket API to get streaming updates.