As a long-term investor in crypto, I want to deeply understand as many aspects of the space as possible. Having started to follow traders and miners like @notsofast, I decided that mining was one such area.
While I’m definitely not someone who’d likely be able to setup a “mining rig”, I did manage to do some mining, and wanted to document what I learned. Also, since there was so much digging around involved in actually getting started, I wanted to pull together the details into the article I wish I’d had available.
So in this post, I’m going to talk about my experience with cloud-based CPU mining, and my experience with cloud-based rental of mining rigs. But first, let’s introduce a couple of key concepts.
For starters, mining is a computational activity in which you calculate hashes in an effort to validate blocks of transactions on the chain of whatever coin you’re trying to mine. The calculation of a hash is performed according to a particular cryptographic hashing algorithm, of which there are several. In the case of bitcoin, the algorithm is called SHA-256.
A hashing algorithm takes any size input, and produces a fixed-length output, from which the input can not be determined. That’s why hashing algorithms are referred to as one-way functions. The process of mining, at least in bitcoin (I haven’t checked if it’s precisely the same for others), involves calculating the hash of a block of transactions, the hash of the block header, hashing those together and looking at the output for something called a “nonce”, which verifies that we’ve found a block.
The miner then broadcasts those hashes to the network, which can verify their work and assign them the reward.
Whether I’m using my laptop computer or a full-bore rig to mine, I only get a reward when I find a block. And that can take a long time. For that reason, mining pools were formed, that aggregate the hashing power of multiple contributors. Whenever the pool discovers a block, the rewards are distributed pro-rata to the pool contributors.
From what I can tell, most mining nowadays is done in pools.
CPUs, GPUs and ASICS
Bitcoin was originally mineable with CPUs on desktop and laptop computers. People later discovered that GPUs (graphics processors) are much better at computing hashes, at which point it became economically uninteresting to mine with CPUs. Finally, task-specific processors called ASICS were produced, which are optimized for the computation of hashes.
There seems to be an order of magnitude in capability between these technologies, with hash power discussed in units of KH/s, MH/s and GH/s, respectively.
As you can imagine, there’s also a cost difference between these technologies. Getting up and running with a GPU “rig” is more expensive than mining on your laptop, and only those willing to make a major investing in mining are using ASICS.
Interestingly, some projects, like Ravencoin, wish to preserve a broader community of miners—i.e. less consolidation of hash power—and design their hashing algorithms to be ASIC-resistant.
Cloud-based CPU mining
Given that I can’t setup a mining rig, my first option for experimenting with mining was to deploy cloud servers (VPSs) at places like DigitalOcean and Scaleway (which even I can do in a few clicks), and then hopefully find some Unix-based CPU mining software.
Fortunately, some Unix-based CPU mining software does exist, and is even designed to allow you to mine a variety of coins, using a variety of hashing algorithms. It’s called cpuminer-multi.
Below are the CLI commands I pieced together to get the software installed and running. This assumes you’ve created a server running Ubuntu 16.04 (the default OS at DigitalOcean, and offered by almost all cloud-server providers) and are logged in as root (and be sure to answer “Y” to any prompts):
Here’s the first command (not sure what it’s doing):
Now we make sure the git version control software is installed:
apt-get install git
Now we install a bunch of stuff that’s going to let us build the cpuminer software on our server:
apt-get install automake autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev make g++
Now we download the cpuminer software:
git clone https://github.com/tpruvot/cpuminer-multi
Now we switch into the cpuminer directory:
…and we build the software:
We’re going to launch the cpuminer software inside a screen manager (called “tmux”) so that we can then close our login session if we want:
Finally, it’s time to issue the command to start our miner! As you’ll see, we’re going to be passing in some information (parameters), including the pool where we’re going to mine and how we’ll be identified there.
To mine Ravencoin, I created an account at the Suprnova pool, then created a “worker”, specifying an arbitrary worker name and password. Also, in your Suprnova account, you have to specify a payout address where you want your earnings sent.
So here’s the format of the command you issue inside tmux to start mining Ravencoin at Suprnova:
./cpuminer -a x16r -o stratum+tcp://rvn.suprnova.cc:6666 -u <user_name>.<worker_name> -p <worker_password>
You can see that the algorithm we’re going to be using is Ravencoin’s “x16r”, which is an algorithm that rotates between 16 algorithms, in an effort to be ASIC-resistant.
There are other pools that don’t require creating an account at all. You simply pass your receiving address in the miner launch command, like this:
./cpuminer -a x16r -o stratum+tcp://ravenminer.com:3636 -u <your_Ravencoin_address>
Couple of things before moving on:
- To escape from tmux, type
d. Don’t worry, though, your miner is still running, but it’s safe now to logout of the server if you like. To kill the miner, run
top, which will show your miner process at the top, quit out of top with
q, and then kill your miner with
I understand that at Suprnova, you should create a different “worker” for each machine that’s going to be mining in your account. At the pools where you don’t create an account, however, you can mine with multiple machines on the same receive address.
Finally, the pools and crypto projects could really help noobs like me by specifying the whole command to start mining. Some just say things “Stratum on port 3636”, and assume you know the rest.
How were the results?
In a word, awful, but that was expected. Using a 16-core “optimized” droplet at DigitalOcean ($320/month or $0.476/hr), I was able to generate 850 KH/s (kilohash per second). Interestingly, with a Scaleway 8-core “bare metal” server ($20/month), I was only able to generate about 65 KH/s. I’m not sure why there’s a 10x difference, given a doubling of cores, but I wasn’t bothered to look into that.
Economically, at DigitalOcean, I was getting about 2.65 H/s/$ (hash per second per dollar), while Scaleway was about 3.25 H/s/$. So one would do slightly better to deploy 13 servers at Scaleway, but, of course, that adds some overhead. (And, as we’ll see below, this is a moot issue anyway.)
Using the DigitalOcean machine, I was mining about 1.74 Ravencoin per hour. With a server cost of $0.476/h, that means I was paying about $0.27 for each Ravencoin.
At the same time, in the #trading channel in Ravencoin’s Discord chat, OTC trades were happening at about 500 Satoshis, or about $0.06 per coin—i.e. 4.5 times cheaper than I was paying through mining. (And those 500 Satoshies represented a 500% price increase with respect to the previous 48 hours, given the news that Overstock had invested in the project!)
So clearly, I’d be better off buying Ravencoin, than mining it. (I noted that almost everybody in the #mining channel were using GPU rigs, and getting MH/s performance.)
The conclusion here is that CPU mining generally makes little economical sense, but it is a convenient way to actually try out and learn about mining.
Before leaving the topic of cloud CPU mining, it should be noted that most cloud-server providers prohibit mining, since most VPSs (virtual private servers) use shared infrastructure, such that your miner software’s consumption of 100% of the CPU, 100% of the time, unfairly impacts other VPS users. At DigitalOcean, for example, they only allow mining on their “optimized” droplets, which use dedicated CPUs, and at Scaleway, you can only mine on the bare metal servers.
(Some providers actually offer GPU cloud-servers. I didn’t experiment with those as their costs are upwards of $1,000 per month, and don’t seem to be available on a per-hour basis. I was actually prepared to try one, but I couldn’t find an answer to the question of whether the software would auto-detect and use the GPU. Since its name is “cpuminer”, my guess was “no”, and I didn’t want to drop $1,000 to find out.)
Renting real mining rigs
The next stop on my mining journey was NiceHash.com which offers a marketplace where you can actually rent time on someone else’s mining rig.
At NiceHash, after setting up an account and depositing some bitcoin, you create one or more pool configurations where you want to mine. For this experiment, I chose the IPBC coin that I’d seen @notsofast mention he liked.
Next, you access the “marketplace” under the “For buyers” menu. This screen seemed to be an order-book of offers to rent hash power.
The documentation recommendeds that beginners create “Fixed” offers, as compared to “Standard”, since there’s only two variables under your control—hash power limit, and total cost.
(After entering those two variables, the order window updates with an estimation of how long your mining will last. I think the maximum time allowed is a few days.)
I set the hash power to 0.2 MH/s, and the amount of BTC I wanted to spend on the experiment, and clicked “Place Order”. On my first attempt, the system responded that there were no matching offers. Adjusting the values slightly, though, my offer was accepted and a graph appeared immediately, showing the state of my mining!
I then switched over to the IPBC pool’s website, did a lookup on my IPBC address, and saw that, sure enough, I was contributing about 200 KH/s of mining hash power to the pool! And then I waited.
Each time the pool found an IPBC block, the website would report a proportional payment to me—based on the number of “work shares” I’d contributed—and those payments soon appeared in the IPBC wallet that was running on my Mac.
How were the results?
Better than with CPU mining, for sure, but still not economically interesting. Using NiceHash, I was paying about $0.60 per IPBC coin, while they were selling on the Livecoin exchange for about $0.40.
According to some users on reddit, the people who profit from using services like NiceHash are those who closely monitor the short-term windows when the rental cost movements lag the price movements of coins. (Perhaps that explains why maximum rental duration is specified in units of days, instead of, say, months or years.)
Renting can also make sense for people who want to speculatively mine a brand new coin that’s not listed on an exchange.
Update: After writing this article, I posted another article about how to calculate the breakeven cost of mining a coin, so that you can determine whether or not it’s economically worthwhile to mine with rented hashpower.
I’m really happy to have spent the time and effort to actually do some cryptocurrency mining. In the process, I learned about how mining actually works, I learned about the role of hashing algorithms, and I learned about the economic realities of cloud-based CPU mining, and GPU rental mining.
Hopefully, getting my hands dirty in the trenches will help me to become a better long-term investor in this space. That’s my objective, in any case.
Next stop on the journey, staking and masternodes. Stay tuned!