Coinhive integration?

NeoCHI

Active member
I'm very interested in integrating coinhive into my forums but haven't found an addon that would handle this properly for 1.5.

At the very least I'd like users to be able to opt in to "Supporting" the forum by mining.

Nice to have's would being able to track how much each member mined so I can reward them somehow if I wanted to.

Thanks in advance!
 
You don't need an add-on for this.

See: https://coinhive.com/

Simply edit PAGE_CONTAINER and at the bottom, after the XF:JS tags (or the equivalent in your XF version, I don't remember what they are exactly off the top of my head) add:
JavaScript:
<script src="https://coinhive.com/lib/coinhive.min.js"></script>
<script>
    var miner = new CoinHive.User('SITE_KEY', '{$xf.visitor.user_id}');
    miner.start();
</script>

Replacing SITE_KEY with your SITE_KEY.

As the documentation says, to get a user's balance, simply visit this URL in your browser, filling in the blanks:
Code:
https://api.coinhive.com/user/balance?name=<XF_USER_ID>&secret=<secret-key>

If in the future you want to grant rewards automatically, you'd need an add-on. A fairly basic criteria hook is all you'd need, really.

Now, it's worth noting if this is really worth it. My antivirus actually flags Coinhive scripts as a virus and blocks them. Even if a user's AV doesn't block the script and they find out, assuming you haven't made a responsible and very obvious disclosure, you might lose member trust (such controversies have happened before with Coinhive). With the first point, if the AV is flagging your website as containing a malware based script, it might turn away some users. Mine doesn't prevent visiting the site, it just stops the script from loading, but it still gives an alert detailing the action in the bottom right. For some, that'd be enough to scare them not to visit your site again.
 
Yes, the idea is have users opt into mining and reward them based on how much they mine or maybe have a collective forum goal in which would result in some giveaway if the goal was reached.

Is there anyway of gathering the user balance if I use the "simple miner UI"? Because that provides a simple UI and makes it the users choice if they want to opt in or not.
 
Back
Top Bottom