Compared to my newer web miner here, this project was very inefficient. You should use the newer one.
Is a Javascript cryptocurrency miner that runs in a users web browser and mines Allium-based coins, namely GRLC.
Concept: Users that visit a website can utilize their spare CPU cycles to support the website. I believe browser-based cryptocurrency mining has a wide potential area to be used in - from such as in-game rewards to as an alternative to marketing ads. I believe browser-based cryptocurrency mining when used properly and with caution, can help support websites while offering a better browsing experience for the end user.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
WebGRLC depends on a couple things. I will assume you have a debian-based system to install dependencies on.
sudo apt update
sudo apt install apache2
sudo ufw allow in "Apache Full"
The last command opens up the firewall to allow traffic to ports 80 and 443.
sudo apt install php libapache2-mod-php php-mysql
sudo systemctl restart apache2
The last command restarts Apache Web Server, and will allow it to use php.
Before we install the WebGRLC Miner, it would be helpful for us to understand how the web miner works. Please skip a bit down to Running the Tests and read the section about index.html, which explains how the web miner operates. Now that you've done so and we understand the web miner, let's install it to our system!
First, let's download all our files into our web server. Typically Apache will look for files at `/var/www/html/' to display, so let's download there:
cd /var/www/html
sudo git clone https://github.com/KorkyMonster/alliumhash-wasm.git
Our WebGRLC miner relies on a PHP script that has to be running on the backend. First let's modify run.php - we need to modify our pool info and the location of ww.txt
. The tricky bit is that we have to make sure that ww.txt can be written to from the php script. Let's create ww.txt and j.txt, and assign all neccesary permissions.
sudo mkdir ~/WebGRLC
sudo chmod a+rwx ~/WebGRLC
touch ~/WebGRLC/ww.txt
touch ~/WebGRLC/j.txt
Then we'll edit run.php
and fill in our pool info and the location of ww.txt
. The now have to edit StratumServer.php
and fill in the location of j.txt
. We finally need to edit w.php
to fill in the locations of both ww.txt
and j.txt
. The values that I used when installing were /home/raptor/utils/ww.txt
and /home/raptor/utils/j.txt
I made a simple UI for WebGRLC in index.html
. Loading index.html
in a web browser should allow you to test whether your installation is working. But first, let's understand how it works:
- When
index.html
is loaded, it loads with it an additional script calledwork_manager.js
work_manager.js
doesn't start mining immediately, it waits for a user to click the start mining button onindex.html
. When the start mining button is clicked onindex.html
, a function is called inwork_manager.js
that initiates the process to start mining.work_manager.js
gets the number of threads to use from Hardware Concurrency API or the user field in UI and spawns that many Worker threads to utilize multithreading- Each worker calls
allium.js
, which is a script that contains hashing functions, which then loadsallium.wasm
which has low-level code to carry out hashing. - Each worker initializes variables needed for mining and awaits work to process from
work_manager.js
. - Meanwhile on the backend, we have a
script called
run.php
being run.run.php
communicates with the mining pool and network and receives any work assigned to it by the pool. It then writes the work to a file namedww.txt
andj.txt
, in a location of your configuration. work_manager.js
AJAX's w.php to get the latest work fromrun.php
and distributes to worker threads, which then start mining, and feeding back found shares and hashrate info at intervals.work_manager.js
continues overseeing worker threads by updating work given by the mining pool and taking action on user UI.
I strongly belive browser-based cryptocurrency mining can reap rewards for both the website and end user, but only if it is managed properly. It is highly advised you leave a minimum of a thread on a user's computer unused. Using too much of a computer's resources can put strain on the system and make the webpage unresponsive. It is also cautioned that this is automatically disabled for mobile devices that rely on batteries. Mining on mobile devices will quickly drain their batteries and could cause damage to the devices.
- PHP - PHP is a popular general-purpose scripting language that is especially suited to web development.
- WASM - WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine.
- A lot of love! ❤️ ❤️ ❤️
Everyone is free to make a pull request if they think this project and can be fixed. I will always review all PRs before merging. If I think it's good, I will!
- KorkyMonster#4304 - Implemented Allium hashing algorithms, optimized miner, implemented hashrate reporting
- Ryan Shaw - Provided low-level (WASM) code
- borlak - Provided php framework and basic front-end structure
This project is licensed under the MIT License - see the LICENSE.md file for details
- Ryan Shaw - ❤️ ❤️ ❤️. Mr. Shaw is a Garlicoin developer, who helped me so much through this project. He was very knowledgable about everything and was able to graciously provide the low-level (WASM) code that was used to make this miner.
- The Blockchain Developers Club - THis community was able to provide insight on hashing functions and lead me in the right path.
- cryptocoin_scrypt_stratum - This was the framework for this project.