Giter VIP home page Giter VIP logo

javascript-emscripten-bitcoin-miner's Introduction

JavaScript-Emscripten-Bitcoin-Miner

This project implements a working JavaScript Emscripten Bitcoin Miner. The purpose of the code is nothing more than a proof-of-concept. Why? It makes perfect sense to me that some websites need ways to fund their operation. However, the idea that they use the resources of my computer (for mining Bitcoins) instead of my own eyes and mind (for processing advertisements) appeals to me a lot.

The core mining (hashing) is implemented in C:

native/miner.c

This code is compiled with Emscripten to JavaScript (with asm.js output enabled):

native/Makefile

Here's the resulting code:

proxy/js/miner.js

The communication with a mining pool is implemented by hand in JavaScript:

proxy/js/worker.js

The miner is using Web Workers to run the processing (it does not detect number of CPU cores to optimize the use of resources though). Running on Intel(R) Core(TM) i7-3720QM at 2.6GHz it reaches:

  • in Chrome 37 the miner reaches ~32 khash/s
  • in Firefox 32 the miner reaches ~220 khash/s

Both parts (compiled hashing code & communication with a mining pool) are rolled together into code ready to be embedded in an HTML document:

proxy/html/test.html

proxy/js/manager.js

The script accepts following parameters: "host" and "port" number of the pool along with the "user" (worker name) and the "password" (worker password).

JavaScript embedded in an HTML cannot connect to an arbitrary host. Therefore, if you do not have your own mining pool on the same host you will have to use a proxy. This project includes also a proxy which is implemented in Python and meant to run on Google AppEngine.

proxy/Docker

proxy/bitcoin-mining-pool-proxy.py

Enjoy!

javascript-emscripten-bitcoin-miner's People

Contributors

altermarkive avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.