STEEM and STEEM Dollar Donations For Livestreamer - with SteemAlerts.com

in utopian-io •  9 months ago

Hey folks! In todays post I'm going to introduce steemalerts.com - A new platform for livestreamer who wants to accept STEEM donations during their streams.

SteemAlerts uses streamlabs to display donation alerts and steemconnect for the authentification. The complete project is a nodeJS expressjs app.

router.get('/steem', function(req, res) {
    if (!req.query.access_token) { //if the url query has no access token redirect the user to steemconnect
        res.redirect(steem.getLoginURL());
    } else {
        steem.setAccessToken(req.query.access_token); // set the access token 
        steem.me(function(err, response) { //request the users steem profile
            response.account.json_metadata = JSON.parse(response.account.json_metadata);
            req.session.steem = {           //and store it in the session
                security_context: {
                    access_token: req.query.access_token
                },
                user: response
            };
            res.redirect("/")       //now redirect the user back to the landingpage
        })
    }
});

After the users logged in with StreamLabs and Steem he can proceed to his Dashboard:

The dasboard consinsts of a small template with a huge amount of javascript code to keep all the informations up to date.
To start SteemAlerts the user has to click the red status message in the menu:

As soon as he click the button an ajax request to /api/donations/add/1 is started:

Now I retreive the account history for the user:
steemAPI.api.getAccountHistory(req.session.steem.user.name, -1, 1000, function (err, result)
and iterate throught all transaction of type "transfer". To avoid that power up transactions are shown I check that the "from" field is different to the current user. In the first request I add all new transactions to the database and set them to hidden.
database.addTX(ele[1].trx_id, JSON.stringify(ele), ele[1].op[1].to, parseFloat(ele[1].op[1].amount), "STEEM", hidden);

Hidden means that they dont appear in the dashboard. No SteemAlerts continuously checks for new incoming transfers of STEEM and STEEM Dollar. As soon as a new transfers was found a SteemAlert calculates the value of the sent STEEM into USD. (Streamlabs only support fiat currencies).

This is how the alert is sent. ele is the transaction and price is the current price for STEEM in USD. The message is built using the transaction as well and always looks like:
@{username} sent you {amount} {currency} If the user set a memo to the transaction the message is extended with: with the message: {memo}

streamlabsapi.addDonation({
    name: ele[1].op[1].from,
    identifier: ele[1].op[1].from,
    amount: parseFloat(ele[1].op[1].amount) * price,
    currency: 'USD',
    message: message
    }).catch(function (e) {
        console.log(e)
    })

Here is an example of a SteemAlerts donation:

As you can see the amount of Steem is beneath the amount of USD so you will be able to keep track of your STEEM donations. Additionally the dashboard will update with the new total amount of donated STEEM and will display the donation with some details in the table.

The live site is available at SteemAlerts.com and is currently in a closed beta phase. If you're interested in SteemAlerts and want to participate find me on the utopian discord and write me a direct message. Join my Discord: https://discord.gg/VhHakyp

Edit Jan 17th 2018

My project was approved by streamlabs.com and is no longer in beta mode! Everyone is now able to use SteemAlerts



Posted on Utopian.io - Rewarding Open Source Contributors

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:  

Nice work, will be useful for the streamers, that s not for me though haha ;)

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

nice idea dude!

Dope shit! Thanks and praise for taking the time to create yet another amazing Steemit project for the community.
Upvoted Followed & Resteemed. Shared on TW, FB & LINKEDIN as well.

You're doing a great contribution here... Congrats ✌

Hey @wehmoen I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for doing this!