top | item 2566365

Javascript Bitcoin Miner

225 points| pizza | 15 years ago |forum.bitcoin.org | reply

142 comments

order
[+] cookiecaper|15 years ago|reply
It is bad to use a bunch of the user's CPU without any notice. They will probably notice that your site makes their computer slow and never come back again. Also, once they find out you've been using their CPU power/electricity/battery life surreptitiously for private, unshared gain, you will probably have some angry customers.

Additionally, does this automatically hook in to slush's pool or something? Bitcoin mining is practically useless on CPU; even the fastest CPUs out get way, way less than 10mhash. The average length of time to find a block at 9999khash and current difficulty is 1200+ days, so even that estimate is over-optimistic, so this isn't worth anything if your users don't sit on your site for 5 years+, unless it's hooked into a pool or some other contraption to pay on shares instead of blocks.

[+] Groxx|15 years ago|reply
Interestingly, from post #9:

  Chrome13-canary: ~15.2k/s
  FF4: ~6.4k/s
  Safari5: ~6.2k/s
  IE9: ~1.6k/s
So yeah, massively massively slower than regular GPU mining. Anyone know of a way to push WebGL into doing hashing functions, and reading the results out?
[+] cookiecaper|15 years ago|reply
And I should add that the prospects of finding any meaningful amount of shares, while much better than finding a block, are still quite low. My GPU can find a couple of shares per minute in a good minute, but it operates at 55.5Mhash, over 10x faster than my CPU (i7-2600K). Consider that most are going to have really slow CPUs and share the processor power with other heavy applications (Flash games), and you might get one share from the best computers in an average 10-20 minute visit if you're lucky. Shares are worth increasingly little and it depends on how you calculate what each share is worth (since btc generation is really totally based on blocks and each pool decides the value / share on its own, etc.), but I really doubt this is a viable replacement for advertisements or any other money-making endeavor for anyone, even the largest websites where people spend lots of time (Facebook, gmail).
[+] endian|15 years ago|reply
way, way less than 10mhash

s/mhash/Mhash/

[+] kristiandupont|15 years ago|reply
Regarding angry visitors, I think it is completely fair if you just inform them of what is going on.

In a way, this is the perfect internet model: I offer my content for free but visitors pay me with cpu cycles. It's superior to the ad-model because it pays according to time spent on the page regardless of who the audience is.

It's too bad that it's infeasible because of the very low rate.

[+] nicpottier|15 years ago|reply
Yes, I'm glad someone actually picked up on this.

I'm watching Bitcoin with a curious eye, but this really nails a pretty novel and interesting aspect of it. That yes, you are paying the site owner for viewing their site, in a way that is (mostly) transparent to you and with billing already captured by your power company.

I haven't actually run it so I don't know just how badly it thrashes my machine, but assuming that can be worked out, this particular idea is the KillerApp(tm) of Bitcoing as I see it.

Actually, now that I'm thinking of it, one giant achilles heal:

If this really takes off and the mass of the internet uses it, then that means the entire mass of the internet can only be monetized at the set rate that Bitcoins are made. Which isn't much money.

But I still think there is something interesting here.. hrmm.

[+] nodata|15 years ago|reply
Why does time spent on the page matter?
[+] pygy_|15 years ago|reply
Going meta:

I've seen in the last few weeks apparently relevant and polite posts that had been flagged dead[1]. One of these was a post by jashkenas in a CoffeeScrit thread. This one could hardly have been more on topic.

Is there a new moderation policy, or is it a bot with a happy trigger?

[1] In this thread, http://news.ycombinator.com/item?id=2566826 , a post by jhuckestein, and http://news.ycombinator.com/item?id=2566797 by csomar.

[+] trotsky|15 years ago|reply
I'd be curious to know the answer to this too - I've seen an increase of "one off" seemingly acceptable posts being flagged dead, and browsing their post history it wasn't cases where they were set to auto-dead.
[+] HardyLeung|15 years ago|reply
Javascript is way too slow compared to GPU, by at least a factor of 1000 or more. If you have 1M daily unique visitor and you manage to "steal" 10 CPU seconds from each of them, the amount of work would be equivalent to 1e6 * 10 / 1000 = 10000 seconds which is about 2.8 hours of one dedicated GPU-based mining machine.
[+] rudiger|15 years ago|reply
Actually, regular CPU miners are nearly 1,000 times slower than GPU miners. I wouldn't be surprised if a JavaScript miner was several orders of magnitude slower than that (ie. a million times slower than GPU miners).

What about using gamers' excess GPU to mine Bitcoins in an installable massively-multiplayer game? Is anyone trying this?

[+] milkshakes|15 years ago|reply
for now. webcl support is not far off, and that's when this could get quite interesting
[+] trickjarrett|15 years ago|reply
Agreed, it is far from the future of super computing. But it provides an interesting first iteration for a potential future model of income off of websites.
[+] ck2|15 years ago|reply
You need a year's worth of 3ghz dual core cpu power to make 50 bitcoins.

This is some impressive code but not practical.

And I don't think visitors are going to like you maxing out their cpu.

[+] seanalltogether|15 years ago|reply
I know plenty of women who spends hours a day playing casual games, if you embedded a bitcoin miner into a free facebook game you might be able to generate some decent revenue while they play.
[+] vegai|15 years ago|reply
Great. So now we will have to start blocking Javascript code from sites we don't trust.
[+] wladimir|15 years ago|reply
I've been doing this for a long time with the Ghostery firefox plugin. It blocks all kinds of trackers and other dubious stuff.
[+] Klonoar|15 years ago|reply
Neat! Distributed computing with JS is an awesome tech trick, some friends and I did something similar back during Node Knockout (MapRejuice: https://github.com/ryanmcgrath/maprejuice).

Curious to see what you guys think of the ethical side of it though - do you let this run on mobile, etc? This will almost definitely cause extra battery drain on mobile devices, you think it's fine to have this happen without user consent? ;)

[+] dave1010uk|15 years ago|reply
BitCoin mining could replace banner ads. I have Flash on my mobile, which often uses lots of CPU usage for ads. You could argue this is the same.
[+] motters|15 years ago|reply
If there is a Bitcoin bubble you can be sure that there will be people doing things like this, regardless of whether it's ethical or not. From the site visitor's point of view they're not getting a cut of the mined coins, so their high CPU usage is purely a waste and annoyance. If widely deployed, this sort of browser based CPU wasting enterprise could bring Bitcoin into disrepute and be an excuse for governments to treat it as a cyber-threat.
[+] AffableSpatula|15 years ago|reply
banner ads are also, on the whole, a waste and annoyance; so not much of a change there

It is probably fair to say most people don't care all that much provided their user experience is not noticeably impacted, but it looks like this work is failing to deliver in that respect. If they manage to throttle CPU usage effectively then this is at least a semi-feasible alternative to "monetizing" traffic.. I find that quite interesting conceptually, even if it doesn't work in practice at the moment.

[+] yatsyk|15 years ago|reply
Idea for browser extension: display warning icon if tab uses all cpu.
[+] pbhjpbhj|15 years ago|reply
So what you're saying is that my FF has being doing this for the last 7 years ...
[+] paulirish|15 years ago|reply
The source of their miner: http://dpaste.com/hold/544515/

It actually starts up a web worker with the exact same file and communicates with itself back and forth, the browser version to the worker version. Not the first time this technique has been used but it's still pretty new.

[+] tlrobinson|15 years ago|reply
Cute, but this is hardly worthwhile unless you have a massive number of users, in which case you probably don't want to piss them off by wasting their CPUs.

I'm getting about 13K hashes/sec with this JavaScript miner. For comparison, my GPU gives me 100M hashes/sec, and even my 12 CPU cores give me 10M hashes/sec with the official Bitcoin client.

So you'd need about 1000 concurrent users at all times to match a single machine. EngineYard SHA1 contestants who used this approach had the same problem.

Now, if Native Client was widely deployed, or you could somehow rig up WebGL...

[+] mikegagnon|15 years ago|reply
PluraProcessing.com pays site owners to farm out computations to their clients. According to PP, site owners can make about $2.60/month/user. The major catch is that the system only works well when visitors have long visit durations (e.g. web-based video games). I presume PP necessitates long visit-durations because short visits won't yield enough computational resources to make computations economical.
[+] rgbrgb|15 years ago|reply
Very interested to see if this could actually be an alternative to ad revenue.
[+] zbanks|15 years ago|reply
Using http://www.alloscomp.com/bitcoin/calculator.php :

On my computer (netbook running Chrome in Ubuntu), bitp.it clocks at 2.2khash/sec. Using this, I'll give 2000hash/sec/user as a conservative estimate.

If you had 1M daily visits, averaging about 1 minute of interaction (high, but assuming you have long-form content), you'd have 12000Mhash/day, or about 2.77Mhash/sec.

Plugging this in with current rates, this ends up being $0.08/day. For 1M views. This is about 3 orders of magnitude lower than just AdWords.

[+] gibybo|15 years ago|reply
I don't think the fundamentals are sound here. Advertising spurs commerce, which creates value. This wastes electricity, slows down users' computers, and does no valuable computation.

It seems closer to stealing from your users (with enormous inefficiency) than something that creates any real value.

[+] Shamiq|15 years ago|reply
As they point out -- you would need a visitor to remain on any given page for a relatively long period of time. Works well for long-form content, but breaks down in shorter chunks.

One thing I'm particularly interested in would be embedding this in a frame similar to stumbleupons web interface and allowing for revenue sharing with the user.

[+] aarlo|15 years ago|reply
So why does the bitcoin economy reward spending processing power?

I guess our economy does too (quant finance)

[+] wcoenen|15 years ago|reply
Because you need some way to inject new coins into the system initially. Bitcoin chose to do this by allowing early users to "mine" the currency.

The traditional approach is to have a central bank which does the minting and printing, and then the regular banks can borrow that money. Those banks then lend that money to their customers, possibly creating more virtual currency by fractional reserve banking.

Bitcoin obviously can't do that because it is a decentralized system. The traditional approach also has the disadvantage that all currency in circulation is ultimately borrowed, so there is always more debt than money unless you allow banks to default. That can only work as long as the economy is growing fast enough.

I think there are even better alternatives, by modeling currency after trust and social capital: http://ripple-project.org/decentralizedcurrency.pdf

[+] caf|15 years ago|reply
At heart, it's because honest nodes spending CPU power to notarise transactions in a distributed manner is what maintains the system's integrity. I suggest reading the original bitcoin whitepaper - even if you find the economics a bit dubious, as I do, the tech is certainly interesting.
[+] esrauch|15 years ago|reply
Anyone care to calculate the actual expected revenue you could get from this?
[+] mtogo|15 years ago|reply
If you have an average consumer box and leave this running during the day, a few USD a year at current exchange rates.
[+] peterbraden|15 years ago|reply
on the ethics of this thing - most people seem to think that using a users cpu without permission is unethical.

My browser is often brought to it's knees by badly written flash ads - is there a difference?

[+] jpr|15 years ago|reply
There is no difference. That's why people who want to retain their sanity disallow Flash. And it's really fucking close that I don't disable all JS too.
[+] dave1010uk|15 years ago|reply
Someone could make a URL shortening service that frames sites, including the mining JS. Users could sign up and get a % from the mined coins on links that they share.

As many people are pointing out that GPUs are faster for mining that CPUs, would you be able to make use of a GPU with WebGL (or GPU-accelerated Flash)? I guess the GPU computations don't fall in the spec of WebGL though.

[+] josephholsten|15 years ago|reply
We thought about how much people would hate us if we did some digg-bar thing like that. We'll leave the being debatably evil to google.

As for the GPU-accelerated JS, check out WebCL: http://webcl.nokiaresearch.com/

[+] VMG|15 years ago|reply
I think a bitcoin browser plugin would be the sanest choice
[+] BCM43|15 years ago|reply
If this gets more people to install noscirpt, I'll consider it a good thing.
[+] josephholsten|15 years ago|reply
I hadn't heard of that! I'll be sure to mention it on our opt-out page, along with adblock.
[+] ccarpenterg|15 years ago|reply
Idea: Screensavers with a bitcoin miner. Like SETI@home. Bitcoin@home!
[+] aw3c2|15 years ago|reply
There ain't many things more annoying than screensavers that make my fans spin up.
[+] kes|15 years ago|reply
But who would get the coin?