03

Definitive guide to Mining Bitcoins

The time is ripe to mine Bitcoins! While the statement would’ve been more accurate had it been said two years ago, it still is a good time to start mining. Now if you don’t understand what mining is then the most simple way to put it would be that it is one of the ways of obtaining Bitcoins and its variants i.e. Litecoins and Dogecoins. Anyone with a computer can mine Bitcoins, the process is that simple. You only need a client and you have to let it run continously for a while till you start generating coins. Or so we may think, but little did you know that with each waking moment the Bitcoin mining process keeps on becoming incrementally more difficult. So the more time you take to get in on the action the lesser of a profit you’ll be able to make.

DEFINITIVE GUIDE TO MINING BITCOINS

In order to spend Bitcoins you need to have some and getting your hands on a few can be quite the task, we take you through the process and let you know the easiest way to go about it.

The time is ripe to mine Bitcoins! While the statement would’ve been more accurate had it been said two years ago, it still is a good time to start mining. Now if you don’t understand what mining is then the most simple way to put it would be that it is one of the ways of obtaining Bitcoins and its variants i.e. Litecoins and Dogecoins. Anyone with a computer can mine Bitcoins, the process is that simple. You only need a client and you have to let it run continously for a while till you start generating coins. Or so we may think, but little did you know that with each waking moment the Bitcoin mining process keeps on becoming incrementally more difficult. So the more time you take to get in on the action the lesser of a profit you’ll be able to make.

Bitcoin generation

Basically, you are crunching an awful lot of numbers to get Bitcoins as a reward in return. But since it is digital you’ll need some mechanism so that people just don’t copy a set of bitcoins and then try to spend it all over again. After all, double spending is a characteristic of digital currency. This is where the whole proof-of-work function comes into the picture. Bitcoin uses the hashcash proof-of-work function as the backbone of its mining algorithm. Every mining software that is working endlessly is trying to create a proof-of-work which makes their work unique and thus entitles them to a set of coins. Bitcoin uses an algorithm called hashcash to generate proof-of-work. It is costly in terms of time and energy consumed to produce for the pre-defined parameters. But at the same time it shouldn’t require as much time to verify a proof-of-work as it takes to produce it. This is why the entire process revolves around scanning for a value that when it is hashed two times with the SHA-256 hashing algorithm, the resulting hash begins with a pre-defined number of zero bits. The average effort needed to hash such numbers increases exponentially with an increase in the number of zero bits required. This same generated hash however, can be easily verified by rehashing the number with a single pass of the double SHA-256 algorithm. So it is easy to verify but difficult to generate.

Then a simple question arises, if it was difficult to create for one machine then maybe two can do the job better. This is undoubtedly true, adding more hardware to the mix will give you more bitcoins but only for a short while. When you increase the number of zero bits you increase the difficulty. And the Bitcoin network has its difficulty parameter readjusted every two weeks so that as time passes and more powerful computers join the network, the rate of creation is kept static. So the more popular it gets, the harder it becomes to generate bitcoins. So much that normal computers can no longer generate bitcoins at a profit. The amount spent for the electricity will far outweigh the value of the generated bitcoins. Yet people continue to mine. This is because of the specialised hardware that has been released which can generate bitcoins at a pace far greater than ever before but while consuming far lesser amount of electricity.

Whenever anyone generates a proof-of-work it becomes part of the blockchain. The blockchain then serves as a ledger for every transaction that ever takes place. This is why all your transactions in the Bitcoin ecosystem can be traced from the very origin. Only after verification is the bitcoin transaction happen. So if anyone would’ve programmed a bitcoin wallet to show a balance of bitcoins that never existed it couldn’t ever be used. This is called the double spending problem and the concept of bitcoin was conceived in order to solve the double spending problem. Whenever digital currency is generated, there is the possibility of copying that currency. And thus creating a duplicate which can be used like the original currency.

Bitcoin does not have this issue thanks to the blockchain. Any person trying to scam the system needs to rewrite a good portion of the blockchain and that can only be done via a consensus. That is, a majority of the clients hosting the blockchain must be convinced that a new addition/modification is infact been seen by a majority of the clients. Unless this happens the new addition/ modification is rejected. So it would take a few of the world’s fastest supercomputers to actually change the balance of the bitcoin economy. All of this makes the Bitcoin system very difficult to scam.

Glossary

Usually reserved for the end, it would be advisable to go through the glossary now itself to get a better understanding of things to follow.

Bitcoins - It is a cryptocurrency that is generated and used within the bitcoin ecosystem. The currency is very volatile and the current value is roughly around USD 900.

Block - Blocks are individual links in a chain of transaction verifications.

Transactions that are outstanding get added into a block and are verified approximately every ten minutes. Each new block generated helps with the verification of all previous blocks since it adds upon the previous one. Data is permanently recorded in the Bitcoin distributed network through files called blocks.

Block Chain - Each block that is generated has the hash of the previous block included in it. This creates a link to every coin ever mined in the bitcoin network. When a lot of such blocks come together you get a blockchain. A block chain can also considered as a history of transactions which is shared by all nodes that are mining or participating in the Bitcoin ecosystem or basically a digital ledger. A complete copy of the bitcoin blockchain of a will have every movement of every coin ever mined.

Difficulty - About every 2016 blocks that are released, the Bitcoin ecosystem adjusts the difficulty of verifying blocks depending upon the time taken for the previous 2016 blocks. This is roughly considered to be an increment of 20-30% of the previous value. The difficulty parameter is adjusted so as to keep the average bitcoin generation rate static and only one block will verified on an average of ten minutes for the next 2016 blocks. This “difficulty” parameter is usually expressed as a number [the difficulty at the time of writing this article was 1,789,546,951]. The difficulty is designed to be inversely proportional to the target.

Double-Spending - Trying to spend bitcoins or any digital currency that has already been spent in a previous transaction

Generate Bitcoins - When a miner finally finds a block, it gets virgin bitcoins as a reward. The number of bitcoins awarded for verifying a new block is 25 BTC for each segment of 210,000 blocks. It used to be 50 BTC per block but this number goes down every subsequent 210,000 blocks or so. It has been 4 years since the inception of bitcoins when the first 210,000 blocks were verified and since the rate of generation is constant, it will be another 4 years before the number of BTC awarded is halved again.The total amount of bitcoins that will ever be mined has been calculated to be approximately 21 million BTC.

Hash - The output generated by a hash function is called a hash.

Hash function - It is a computer algorithm which takes any input data and then runs it through a few calculations and shifting processes before generating a fixed length output called the hash. Passwords are commonly stored as a hash so that your actual password is never stored anywhere. Depending on the algorithm used, the probability of two inputs having the same hash does exist. In the Bitcoin system, a hash is difficult to produce but easy to verify and forms the backbone of the whole mining process.

Hash rate - The number of hashes calculated by the hardware is the hash rate. Commonly used indices are Megahashes/second and Gigahashes/ second.

Miner - It is a computer software or a hardware that is designed to calculate the hashes needed for the inception of a new block. The miner also gets a reward in the form of bitcoins and transaction fees for aiding in the creation and the maintenance of the bitcoin blockchain.

Node - Every participant is a node in the bitcoin network, certain client allow you to save a copy of the blockchain on your computer while some don’t. Nevertheless, they are both nodes.

Satoshi - The smallest unit of a Bitcoin which amounts to 0.00000001 BTC is called a Satoshi after the creator of Bitcoin i.e., Satoshi Nakamoto.

Transaction Fee - This is a fee that is added voluntarily to any transaction so as to add the transaction to the block. The fee also determines whether a transaction will be added or not since a higher transaction fee gains priority over lower transaction fee. Since it is voluntary it may be added with any transaction but it is the sender who always pays the fee since bitcoin transactions are always one sided. For transactions that are large which means a high addition needs to be done to the blockchain a fee is expected and charged by most online services.

Virgin bitcoin - When a miner generates a block that has never been spent a Virgin bitcoin is produced as a reward. Thus it is the only true anonymous portion of the bitcoin system. All subsequent transactions can be traced back to the virgin bitcoin.

Mining

Anybody can mine bitcoins, there is a lot of material available online which can guide you through your choice of hardware and software. We’ve gone through some of them to curate all the methods and the time taken to generate bitcoins with each of them. First, we will look at the different hardware that is available in the market for mining bitcoins.

There are different types of hardware available in the market. You can use your ordinary computer [or your super-awesome-rig, whatever you call it] to mine or you can purchase specialised hardware made for mining and nothing else. The hash calculation process is very simple but the sheer volume of calculations is quite taxing on the system. We have four popular options on a broad scale. Along with each hardware type will be a chart detailing different models of each hardware available in the market and the hash rate it offers in MHash/second(higher is better).

1. CPU 
2. GPU
3. FPGA 
4. ASIC

CPU

The CPU is simply the Central Processing Unit or your computer’s processor. This is the easiest and the most commonly obtainable hardware. Also it would be prudent to mention that you don’t need to go and get a separate processor at this moment.

The problem with using your CPU is that it isn’t designed for the volume of calculations involved. You will be able to mine coins in the long run but the costs associated with it will be astronomical and in no way will you be able to break even. The only place where CPU based mining becomes feasible is for criminals who have botnets that mine Bitcoins on all infected computers and according to a recent report, India ranks 4th in the number of PCs having malware mining Bitcoins.

GPU

The Graphics Processing Unit is the processor that sits in the heart of your graphics card or more recently on your main CPU itself in the form on on-chip GPU. GPUs are more focussed towards mining since they have a reduced instruction set compared to CPUs. CPUs are designed to calculate a wide variety of instructions hence the focus is more on compatibility and less on volume. GPUs on the other hand have a much reduced instruction set in comparison and can crunch out a lot of numbers in a short amount of time.

Needless to say, AMD cards are way better than NVIDIA’s offerings and this is because of the architecture they have. AMD’s GPUs have many simple shaders that run at low clock frequency while the NVIDIA design has a lot lesser CUDA cores which run at a relatively higher frequency. So AMD gets the upper hand by having way more parallel processing throughput, when we compare the AMD 6990 to the NVIDIA 590 we can see that :

•    AMD Radeon HD 6990: 3072 ALUs x 830 MHz = 2550 billion 32-bit instruction per second

•    Nvidia GTX 590: 1024 ALUs x 1214 MHz = 1243 billion 32-bit instruction per second

Right off these numbers we can see that AMD is ahead by twice the margin. Another factor is how the instruction sets are implemented in the two competing devices. AMDs instruction set is capable doing what NVIDIA’s instruction set does in number of steps. This significant advantage in terms of time combined with the sheer raw output puts AMD ahead of NVIDIA.

FPGA

A Field Programmable Gate Array is a chip that comes as a blank slate. You can mount the chip and then program it to do whatever you want to get done. This is the reason why the “Field Programmable” part of the name exists. Now these are fabricated according to order as the number of logic gates on each chip can be customised. Also there are a lot of FPGA packages available for cheap, you can simply purchase them in bulk and start programming each chip to mine bitcoins. They are also quite cheap but since the design isn’t streamlined, it isn’t as fast as the ASIC but it is way faster than a CPU and comparable to a GPU.

We can see that the Mini Rig by Butterfly Labs is as good as an ASIC miner even though it is FPGA. And most of the FPGA are comparable to GPUs.

ASIC

Application-Specific Integrated Circuit” are basically designed from the ground up to do just one particular task. They are absolutely useless for any other function. These are the fastest sort of mining hardware at the moment.

There are some manufacturers like Avalon, ASICMiner, and Butterfly Labs etc., who have released hardware based on ASIC chips which are highly evolved for bitcoin mining. For a little comparison on which hardware is better you can check the following link https://en.bitcoin. it/wiki/Mining_hardware_ comparison

Pick your coin

There are a lot of alternatives in the Cryptocurrency universe. Bitcoins have become ridiculously difficult to mine and only ASIC machines are actually worth the effort. Other currencies, however, are catching up. You do have Litecoin and Dogecoin which are currently the popular alternatives to Bitcoin. They do not in any way have the same returns but consider these coins to be in their infancy. If you do get in on the action now then hopefully in the next 4 years you could possibly be a multi-millionaire. The current exchange rate stands as follows.

•    Litecoin - 1,500 Rupees/coin
•    Dogecoin - 5 Paise/coin

Litecoin is relatively difficult to mine than Dogecoins but it has already started gaining traction so that makes it a viable investment.

Solo / Pool / Rental

Mining is by no means an easy task. In the next few paragraphs you will come to know how difficult mining solo is so why don’t we look at some numbers.
Let’s say you have a good rig which can handle three AMD HD 7970 cards in CrossFire configuration. Each card gives an estimated 700 MHash/s but the CrossFire configuration will give you 1950 MHash/s on an average. The electricity cost per kWh in India is roughly 20 paise / kWh when generated. Consumer rates are even higher and vary from place to place. The current Bitcoin generation difficulty is at 1,789,546,951. Under these conditions we can calculate the rate of generation.

As you can see, with such a configuration that has three GPUs totalling Rs. One Lakh you only end up with 0.01 USD per day after subtracting electricity costs. This is ridiculously depressing for someone who spent close to a lakh for purely mining these coins. If you aren’t part of a pool then your profitability goes down even further since you will only generate one block every 124 years. That’s right, more than a century is needed and that is why solo mining is only for those who have a supercomputer(s) at their disposal.

Pool mining is another aspect where you do have the same rig but there are a lot many folk just like you who come together to form the pool. This pool then cumulatively works to solve one block and thus the success rate is much higher and increases as the number of participants in the pool goes up. While this also means that the share that each user gets is way low, it does guarantee to certain extent that you will mine some bitcoins out of the venture rather than solo mining wherein uncertainty looms over you for 124 years.

The last option is to rent processing power. Imagine that there are people who can get you the hardware resources but don’t have the money to fund themselves. They turn to consumers and start offering rental services. In this method, you pay to get a certain processing power. They do everything for you so that all you need to worry about is getting your money’s worth in time. That is the problem with upcoming hardware and services. There isn’t any guarantee and some only accept payment in Bitcoins, so there is no way of getting your money back.

Butterfly labs is one company that has delivered on their promises and are now seeking customers to buy into the rental business. They charge USD 10.53 / [GHash/s]. So if you do spend the same amount as for the triple crossfire AMD setup then you pay close to USD 2,499. Let’s run the calculation again now.

Now power costs are irrelevant since you are not paying for that and all you are investing is for the processing power. This means that in just 49 days you will mint enough bitcoins to break even. Everything after that is pure profit. The rental agreement lasts for one year so that means USD 16,817 of profit over a year. Seems too good to be true? Well, these calculations are based on the current difficulty rate and as time goes by this will increase and you will find it more difficult to mine. That means that the returns reduce significantly. Moreover, they haven’t started the service yet which means by the time they do open their doors to the general public the profitability goes down even further. Since there is no clear release timeline at the moment we can’t calculate the estimate for breaking even your initial investment.

There are plenty of tools available online to help you get estimates on your hardware. Check out http://www.bitcoinx.com/profit/ for a well thought out calculator.

Software for mining

The hardware is just one part of bitcoin mining. You need to worry about the software as well. There are quite a few software but we’ll mention the more popular ones that are widely supported.

1. BFG 
2. BitMiner
3. BTCMiner 
4. cgminer
5. Diablo 
6. EasyMiner
7. gMinor 
8. GroupFabric
9. MPBM 
10. Phoenix
11. poclbm

Not all of them support GPUs and ASIC and lastly, FPGA mining. One that does all three is cgminer, however, it may be a bit difficult for beginners to fiddle with since there is a fair bit of tweaking involved in getting it to work. We don’t know if you’ve noticed but the GPU lists in the previous section did not feature recent GPUs, that are because the high end GPUs have undergone a slight architectural change and it will be a short while before these software start working on those GPUs.

If you are going to be using ASIC or FPGA then you need to figure out which software out of these is supported by your hardware. As for those you wish to mine on their computers, cgminer should be more than sufficient.

Join a pool

If the numbers weren’t convincing enough then we’re letting you know that solo mining is as good as dead. You need to join a pool in order to actually get something out of all the effort you’re going to be putting in. There are plenty of pools out there but you need to join up in a pool with a lot of participants. The following four have the highest number of participants and the highest output.

•    Slush’s pool (mining.bitcoin.cz)
•    BTC Guild
•    Eligius
•    GHash.IO

When you register an ID at each pool, you will be given a worker ID and PASSWORD. For each worker [i.e. individual machine] you need to create a new worker ID and PASSWORD. If you own 5 ASIC machines then 5 IDs and PASSWORDS will be needed, one for each. You can join multiple pools as well and then gather different worker IDs and PASSWORDs from each pool.

cgminer Example

Let’s say you’ve finally got the hardware together and are ready to mine a few bitcoins. We’ll walk you through a simple cgminer command line. At each pool you’ll get a pool URL and a PORT. Aside from that you need to get the following ready.

•    Hardware [GPUs/FPGA/ASIC]
•    Appropriate drivers installed
•    For GPUs you need to install the OpenCL package from the respective manufacturer

AMD

http://developer.amd.com/tools-and-sdks/heterogeneous-computing/amd-accelerated- parallel-processing-app-sdk/downloads/

NVIDIA (https://developer.nvidia.com/opencl)

•    Have cgminer installed

Command line:

For mining in a single pool all you need to do is use the following command line and replace the pool:port with the url given to you and the username and password with the appropriate worker ID and PASSWORD. cgminer -o http://pool:port -u username –p password

For multiple pools you need to chain the commands one after the other and create a huge command with all URLs, worker IDs and PASSWORDs.

Multiple pools:

cgminer -o http://pool1:port -u pool1username -p pool1password -o http:// pool2:port -u pool2usernmae -p pool2password Press enter and if all goes well, you should start mining and see something like the image on the previous page.

There are a lot more clients and covering each and every usage scenario for all of them wouldn’t be possible so it would be best to join an online Bitcoin community and find out if others with your same hardware have found convenient software to use.

That’s about it for generating bitcoins. Once you’ve started on this you need to figure out how to use that currency. The next two chapters focus on usage of bitcoins and other cryptocurrencies.