During the last year, I’ve had a little side project at our office related to cryptocurrency mining and I thought I’d try to shine some light to the topic from the practical side of things. It may save you a couple of moments of googling.
Cryptomining In Practice
Most of you probably have heard already about cryptocurrencies such as Bitcoin and Ethereum, or of the side effects of the cryptomining boom (eg. cryptojacking and cryptomalware). But what if you’d like to mine cryptocurrencies with your own hardware - ie. how to do it, what to take into account and where to start? The purpose of this short blog post is to save you some googling time and to put together some basic information on cryptomining in practice.
What is cryptomining?
I am maybe oversimplifying things a little bit but cryptomining is basically a task of calculating a hash based on a piece of data. Sounds simple, right? Without going any deeper on what is being calculated and how, you can also think of cryptomining in terms of a lottery.
Let’s say you are taking part in an Ethereum lottery and the winning “number” is a hash. You take part in the lottery by having your PC calcute a hash (blindly guessing the right hash). If you guess correctly (ie. find a block), you receive a reward paid in Ethereum cryptocurrency. In real life, you could purchase multiple lottery tickets to have a better change of winning. Similarly, the more performance your computer has, the more hashes it can solve per second and the more chances you have on winning in the cryptomining lottery.
Different kind of algorithms
You’ve probably heard of different cryptocurrencies, such as Bitcoin, Monero or Ethereum. From an ideological and technical point of view, all these cryptocurrencies are quite different from each other. But what is the difference between these cryptocurrencies from a miner’s perspective? Well, it all comes back down to the hashes. Different cryptocurrencies use different hash algorithm implementations. For example, Bitcoin uses the SHA256 algorithm, Ethereum uses Ethash and Monero uses CryptoNight.
The hashing algorithms can be broadly divided into two different categories: memory intensive algorithms and not-so memory intensive algorithms. To a miner, this has big implications on choosing the right kind hardware to solve a specific kind of hashing algorithm. In other words, some mining hardware may be specialised to solve certain hash exponentially better but not be suitable for solving any other kind of algorithm.
CPU, GPU, ASIC Mining
From hardware point of view you have three options in order to mine cryptocurrencies.
ASIC based mining hardware is most commonly used to mine algorithms that are memory inexpensive, like Bitcoin. If ASIC is not familiar, you could think about it as a computer that is specialised to solve a specific task. Unlike a personal computer which is a general purpose computer, ASIC cannot solve any other task that it hasn’t been built for.
GPU and CPU based mining is most commonly used to mine memory intensive algorithms, such as Ethereum and Monero. Memory intensive algorithms are said to be ASIC resistant because the hardware cannot be customised for the sole purpose of solving these hashes.
So, what’s the difference in speed? The more hashes the better, right? Well, in terms of increasing your chances of hitting that sweet grand prize of blockchain lottery, yes. But things are not that simple when you take into account the difference in algorithms and difference in hardware.
In the case of mining Bitcoin, an ASIC miner such as Antminer S9 that costs about $5000 can hash about 13.5 Terahashes (TH) per second. A top-of-the-line $1000 GPU Geforce 1080ti can hash about 4.5 Gigahashes per second and a typical $400 intel i7 quad core processor can hash about 10 MH/s. If you compare the hashes-per-dollar ratio, it becomes quite clear fast that the GPU and the CPU miner can’t even compete against ASIC miners on solving memory inexpensive algorithms. But if you were mining Ethereum, our ASIC miner wouldn’t be able to handle it as it’s not designed for it. Nor is it at the moment economical to create such a miner due to price of memory for ASIC circuitry.
How to Get Started
Whoa, lots of things already and we haven’t even gotten to the core of the topic. So, how to get started? I would first suggest starting with estimating the profitability of mining. I have used whattomine.com where you can insert your own hardware, hashing speed, the cost of electricy and cryptocurrency exchanges to get a list of estimations of profitably minable cryptocurrencies.
After that, you’ll need the hardware. If you went the ASIC route of mining, you’ll need to acquire an ASIC miner. If you are going for the GPU & CPU mining, you could just start with any computer and then extend it as time goes by.
With GPU & CPU mining, you will also need some mining software. There exists a multitude of different mining software depending on what cryptocurrency you are about to mine, what brand of GPU you own, or if you are mining only with a CPU. I have used Xmrig, XmrStak and Claymore mining software. There are also dedicated mining operating systems which will simplify configuring your mining rig such as EthOs.
And of course you’ll also need a wallet or an exchange account where your mining profits will be sent to.
Different ways to mine
Alright, lets say you have chosen the cryptocurrency you wish to mine and you have a miner set up. Now you need to make a decision if you want to do single or pool mining. Most of the time, you will want to choose pool mining. The difference here is that in a mining pool, every pool member is participating on the calculation of a hash and when a block is found, the rewards are shared with all the pool members according to their given workload. Single mining is a good choice if you have enough mining power by yourself in comparison to the total hashing power of everyone else mining the chosen cryptocurrency but if you haven’t invested a few hundred thousand’s worth of money into the mining hardware, you’ll get more consistent rewards from mining operations by just participating in a mining pool.
There’s also a third option which is leasing your mining power to a third party, for example via Nicehash. Using Nicehash is mostly automated and you can benchmark your current system to find out most the profitable hash algorithm to solve and then lease your mining power for that specific use.
Things to Consider and Lessons Learned
Price of hardware: Especially GPUs have gone way up in price. It might be hard to find a certain piece of graphic card for a decent price or the wait times might be long. Also, the prices of GPUs on the second hand market have increased significantly.
Price of electricity: If you enjoy a luxury of free or almost free electricity, it will increase profitability of cryptomining.
Taxation: In Finland, cryptomining is taxed as income tax from the moment the cryptocurrency is mined and any profit between mining and selling is taxed as capital tax. Also, the losses in cryptocurrency trading are not tax deductible.
Volatility: The cryptocurrency market is highly volatile. Mining profits will fluctuate from day to day by tens of percents.
Handling downtime and optimizing: Eventually, if you go with the mining route you’ll be tempted to optimize your hardware and minimize downtime of your rigs. All of this will take some time but it can also be rewarding. By overclocking GPUs and CPUs I’ve gotten a 10-15 % performance boost in cryptomining.