28

I don't have a great understanding of how bitcoin mining works, but how useful would a JavaScript miner be for collecting revenue from visitors? Stupid question, but if I put the user in as part of a mining pool, must their computer actually find a hash in order for me to make revenue? Is this at all practical?

3
  • 1
    You will have to explain to the revenue service why you make this income in bitcoins. Using the website visitors' electrical energy for mining bitcoins could be seen as theft. Commented Jan 27, 2016 at 19:38
  • This was a question well ahead of its time. See COINHIVE and MONERO! Commented Jul 24, 2018 at 19:41
  • @PGCodeRider Thanks! I was just in high school 😂 Commented Jul 25, 2018 at 16:36

3 Answers 3

33

Javascript has access to OpenGL ES, including shaders, so it has access to programmable parts of the GPU at nearly native speeds. I think that a smart kid might be able to build a fragment shader that does SHA256 hashing, which outputs to the stencil buffer, so that Javascript has a 2-way communication channel with the GPU.

So yeah, you could probably use javascript to mine at really nice speeds. Maybe 70% or 80% of what an OpenCL GPU miner does?

[Edit] oh look, someone already built a fragment shader that does that
[Edit 2] and an actual JS/WebGL application

4
  • 1
    Is it actually working for you? Because in chrome it shuts down the tab. Commented Apr 27, 2013 at 22:43
  • 2
    It's the fact that it once did work that counts, as it proves it can be done again. Commented Apr 27, 2013 at 23:11
  • 1
    @SalvadorDali Ensure you have Hardware Acceleration enabled. Take a look here webupd8.org/2014/01/enable-hardware-acceleration-in-chrome.html
    – m3nda
    Commented Jan 4, 2016 at 2:57
  • 1
    This really is an excellent answer. Thanks! :)
    – user5171
    Commented Jan 14, 2016 at 6:38
7

It would not at all be useful for Bitcoin mining. However, it may be useful for other digital cryptocurrencies, such as Litecoin or PPCoin.

3
  • 2
    In the header you should put (For consideration), "You are now mining Cyptocurrency for funding the website and the owner. This is recommended if you would like to help but can't donate. [Turn Off]" The turn off function is needed so people wont be mad with you.
    – user25249
    Commented Apr 28, 2015 at 0:34
  • Monero seems to be the currency of choice here in 2017. It has become epidemic. gizmodo.com/… Coinhive is not shy about it. They offer two versions. One asks for permission and the other does not. coinhive.com Here is a review: medium.com/@MaxenceCornet/…
    – SDsolar
    Commented Dec 1, 2017 at 18:42
  • It seems especially useful if you place these in a site and run them from millions of machines as a distributed effort. en.bitcoin.it/wiki/Distributed_miner
    – scape
    Commented Oct 10, 2019 at 14:47
2

Not practical at all. Most probably the users would be just pissed of. Right now it is not even practical to mine with GPU-s, not to mention CPU-s and for sure JS.

Regarding the question: "if I put the user in as part of a mining pool, ..."

No, it is not important that he would find a hash. It is working this way. Your all workers are calculating hashes (does not matter if you find the right one or no). If a miner mined something at that time, the miner calculates how much work you have done and gives you the amount of bitcoins. So if you contributed 5% - you will get 5% of 25BTC and in case of some pulls fees. If pull mined nothing, you get nothing.

So in total, if you do not want to piss of users, do not do this.

5
  • 4
    if you do not want to piss of users, do not do this. Ads annoy me; paywalls alienate your community; and making content isn't free. If you want to make content and put it on the web, what are you supposed to do?
    – Nick ODell
    Commented Apr 27, 2013 at 17:53
  • 1
    There are plenty of websites making great and expensive content that can easily exist with a business model solely based on advertisement. Commented Apr 27, 2013 at 18:03
  • @NickODell The thing is that you need to be clear for a user that you are using part of his computational power for something. People already used to ads, so it does not bother them too much. This is completely different. How would you feel if you get a program for viewing video, but somewhere silently it is used to generate hashes? You have no idea about this behavior and how would you feel when you read this on some forum? So I think that your -1 is absolutely inappropriate. I just mentioned to the OP what might happen. Commented Apr 27, 2013 at 20:20
  • 2
    As long as you're up-front clear with your site visitors, and your javascript has a governor of some kind so it doesn't suck more than, say, 25% of the GPU's processing power, I don't see why this would be unethical. It could be thought of as a form of hassle-free micro-payments, where you put free (and ad-free) content yet still manage to make ends meet!!
    – Joe Pineda
    Commented Jun 14, 2013 at 22:25
  • 1
    While not practical, in a scenario with only browser and a gpu would work. Think in a way to mine remotely with no software install at all. Last time i've tested Javascrip mine I face lot of problems too :V
    – m3nda
    Commented Jan 4, 2016 at 3:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.