How to calculate mining profitability

In this article, I’m going to walk through an example of how to calculate mining profitability.1 It’s important to make this calculation when considering the rental of hashpower. In this example, I’ll be looking at the Haven Protocol coin, $XHV.

Calculating our breakeven cost

Platforms that rent hashpower usually specify the price in BTC per unit-of-hashpower per day, where unit-of-hashpower is whatever makes sense for the particular coin. In the case of $XHV, which uses the cryptonight-heavy algorithm, the hashpower unit is KH/s, or kilohash per second.

So what we want to determine is the breakeven cost of mining in units of BTC per KH per day.

We start with the data available at our pool. Almost all pools operate the same user interface software, so you’ll nearly always see a screen like the following, regardless of the coin you’re mining.

Now let’s make our calculation, assuming all variables stay constant over a period of a day (which they won’t, but we’ll get to that later). Remember, what we’re trying to calculate is the revenue in BTC per KH/s per day.

  1. Blocks per day — Our pool estimates finding a block every 11 minutes. There are 1,440 minutes in a day, so our pool should find 1440/11 = 131 blocks per day .

  2. Blocks per hashpower — Our pool has a total hash rate of 872.4 KH/s, which means our pool will be finding 131 blocks/872.4 KH/s = 0.1502 blocks per day per KH/s.

  3. Reward per block — The Haven network is currently rewarding 32.6 $XHV per found block.

  4. Earned coins per day — For each KH/s of hashpower, we’ll therefore be earning 0.1502 blocks/day * 32.6 XHV/block = 4.90 XHV/day. (You can double-check this number using the pool’s calculator, but it’s good to understand how it’s determined.)

  5. Revenue per day — For each KH/s of hash power, we’ll therefore be earning 4.9 XHV/day * 0.00007329 BTC/XHV = 0.000359 BTC/day

And there we have it, our breakeven hash power cost for mining $XHV on this pool is 0.000359 BTC/day.

Should we rent hashpower?

With that figure in hand, let’s go see if it makes sense to rent hashpower to mine this coin. At one site, here are the rigs which are currently available for mining the Cryptonote-Heavy algorithm:

As we can see, the lowest cost per KH/day is 0.00049 BTC which is above our breakeven cost. Therefore, it would not be profitable to mine this coin.

So the only case in which it’d make sense to rent hashpower to mine this coin, under these conditions, would be if we couldn’t outright purchase the coin elsewhere, and we expected the price to appreciate.

What can change?

Let’s imagine you’ve made your analysis, the rental cost is below your breakeven point, and you’ve booked a day of hashpower. What can change?

  • Your pool’s net hash rate can change as other miners enter and leave. An increase in hashpower should result in more blocks being found by your pool per day. Likewise, a decrease in hashpower should result in fewer. In the former, you’ll be receiving a lower percentage of a higher number, and in the latter you’ll be receiving a higher percentage of a lower number, and hopefully the result would be net-neutral for you.

  • My understanding is that proof-of-work networks dynamically adjust the mining difficulty in order to keep the average block discovery time constant. That’s how we can pretty accurately predict when the last bitcoin will be mined, as its average block time should remain 10 minutes. In the Discord chats, some claimed to have heard of coins that change block times. If that’s the case, then such a change during your rental period could affect the breakeven cost.

  • The market value of the coin could change as well, which, everything else remaining equal, would either raise or lower your breakeven cost.

  • Finally, the value of the denominating currency bitcoin could change.

So the breakeven calculation is an initial condition that could change during the term of your rental, and so the difference between what you’re paying and your breakeven represents a margin of sensitivity to those changes.

Conclusion

As you’ll have noticed from my previous articles, I’m transitioning from the world of traditional investing, to the world of crypto investing, and in the process am doing a lot of hands-on learning to make sure I understand the ins and outs of this space.

Through this blog, and for the benefit of new entrants to this space, I hope to write articles that simplify some of the complex topics that I’ve struggled with, including details that many others have glossed over or left out entirely.

I hope you’ve enjoyed this one about mining profitability, and if you have any questions or feedback, don’t hesitate to leave a comment below or email me through the contact form.


  1. Shout out to Haven Discord user @tomfer and legendary miner @notsofast for their help with this article. 

Learning about cryptocurrency mining

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.

Hashing

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.

Pooling

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):

apt-get update

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:

cd cpuminer-multi

…and we build the software:

./build.sh

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:

tmux

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 control-b followed by 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 kill <miner_process_id>.

  • 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.

Conclusion

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!