There are generally two types of articles out there describing how bitcoins are mined: the dense and technical, or the simple and vague. This article will attempt to strike a balance between the two by starting with the foundations of Bitcoin and working up.
You probably know that mining creates new bitcoins, but its underlying purpose is actually to verify transactions, keep the record of those transactions up to date, and secure the bitcoin network from thieves and hackers.
Jake Smith (@BeijingBitcoins), author of the Bitcoin News Roundup newsletter, says, “Many people who denounce bitcoin as a scam or ‘internet funny money’ fail to recognize the fact that it is in fact a revolutionary new invention, perhaps as important as the invention of the internet or email protocols.” To understand Bitcoin mining, you first must understand the blockchain, which is one of the defining qualities that makes Bitcoin so unique.
The blockchain is a record of every single Bitcoin transaction that has ever taken place. Ever. It serves as a public ledger for everyone to see. When you download and install the original Bitcoin client on a computer, you also download the blockchain, which constantly expands as more transactions take place around the world. Note that the blockchain is getting quite big at this point, so most modern Bitcoin wallets don’t contain the entire thing.
“Casual users have absolutely no reason to ever download the blockchain. I’m as hardcore of a user as they come and I’ve never even downloaded it,” Smith says. “One should only intend to download the whole thing if they plan on running a node or mining.”
The blockchain may as well be written in stone, because it’s exactly the same on everyone’s computer who has the Bitcoin client installed. “It’s impossible to go back in time and reverse transactions or edit the information,” Smith explains. When you want to send bitcoins to another user, the miners all verify that the address you are sending the coins from actually contains enough bitcoins to complete the transaction. Smith says, “It’s possible to create a transaction input that makes it look like I’m, for example, sending you five coins when I have zero coins. But as soon as that goes through the miners, it will be rejected as I do not have the balance to cover it.”
Every 10 minutes or so, new transactions are added to the blockchain in blocks. Each new block contains two important things: a list of every single transaction that took place around the world in the last 10 minutes, plus a code – called a hash – that references the block that came before it, thus the “chain” part of the blockchain.
It’s the job of miners to take these two pieces of information and condense them into a new hash that fits a certain criteria (it must start with a certain number of zeros), which takes significant computational power. The difficulty of doing so increases (more zeros needed) for every 2016 blocks added, or about once every two weeks. Essentially, they are trying to solve, as Smith puts it, “an arbitrary problem in order to find this ‘magic number’ with an ever-increasing difficulty to ensure that as more computing power is thrown at the network, there is still only an average block time of around 10 minutes.”
These hashes are much easier to compare rather than trying to keep track of every individual transaction in the world. And because each one references the hash that came before it, it revalidates every single transaction repeatedly down to the original “genesis” block.
Risks and rewards
Bitcoin faces two plausible attacks: traders who try to spend or sell the same bitcoins twice, and malicious miners who try to inject fake blocks into the system so they can receive new bitcoins. Mining is a way to secure the network from both these attacks.
The “double spending” problem is minimized because only one of the two transactions will ultimately make it into the blockchain. Even if both are verified at first, miners continue to validate them as more blocks are added until one or the other wins out. This is why many exchanges wait until a block has been validated six times (takes about one hour) before accepting a trade.
Injecting fake blocks requires more trouble than it’s worth, so long as there are more miners than hackers verifying the real transactions.
In return for their service, miners who successfully “solve” a block are rewarded with 25 bitcoins plus some transaction fees. This number is cut in half every 210,000 blocks, or about once every four years.
How to start
These days, mining bitcoins usually requires special hardware. When the cryptocurrency was in its infancy, it could be mined using personal computers because the difficulty was very low. But as more miners enter the fray and computing power rises, the system automatically makes solving blocks more difficult in order to control the influx of new bitcoins onto the network.
ASIC mining is the preferred method these days. It’s a microchip specially designed just for solving the hashing algorithm used by Bitcoin (SHA-256, which is used by people around the world for encrypting information). The software for mining is typically open source and free. The software connects the users to their mining pools, runs the algorithm to solve the hash, deposits the miners’ earnings into their bitcoin wallets.
The barrier to entry for miners is increasingly high, as their overhead costs include both the hardware and the large amounts of electricity required to run it. To increase their chances of solving a block first, most miners join mining pools, where they combine their computational power remotely and distribute the reward across all members. Each member’s cut is “proportional to each miner’s percentage of the pool’s total computing power,” Smith says. Unless you’re investing some serious dough into a house full of mining machinery, mining without a pool is effectively like playing the lottery.
These days, two major mining pools make up almost half the market share of miners: GHash.IO and Discus Fish. The top 10 pools account for about 90 percent of all the bitcoins mined. Each pool is set up like a business, so they each have their own guidelines, fees, and method of splitting rewards. The bigger the pool, the better chance you’ll have of getting a reward, but that reward will be spread thinner amongst members. Each mining machine, or “worker,” can be assigned to one pool at a time. It’s best for the health of the bitcoin network to join less popular mining pools so as not to let one group monopolize everything.
Solving a block is done purely by brute-force – essentially guessing until you reach a solution that fits. It’s sort of like a lottery you can play as many times as you want and as quickly as your mining equipment can run. Those who buy more lottery tickets have a better shot at winning, but they can’t dominate the entire system.
It’s difficult to say how much money one can earn by mining bitcoins because of the many variables such as your mining pool’s number of members and method of divvying up rewards, hardware costs and performance, and cost of electricity. You can, however, input the details of your personal setup into this profitability calculator to get a sense of how much you’d be making if you were to go it alone. You can use this table to help calculate your system’s hash rate.
For example, my gaming PC has an AMD Radeon 6850 graphics card (graphics cards are preferable to CPUs for mining, but still far inferior to ASIC and other hashing hardware). The chart tells me my hash rate is about 245 mega-hashes per second, and I know my computer’s power supply runs at a maximum of 700 watts. At that rate, it would probably take me several thousand years to successfully solve a hash by myself, so it’s not a worthwhile investment.
Casual miners are better off buying a few small 10 giga-hash miners like this or even USB-powered miners like this that are below US$300 each. More serious miners will have to pay north of US$2,000 for either ASIC cards or pre-made machines. Let’s say you spend US$1,000 on four 10GHps miners for a total hash rate of 40GHps.
According to the profitability calculator, that will return an average of 0.0012 bitcoins (US$0.72 as of press time) per day, not including hardware and electricity costs. Not exactly instant gratification, and keep in mind the difficulty periodically rises, so old hardware will be outclassed by new hardware and returns on investment will diminish.
Currently, just over 13 million bitcoins exist. Only 21 million will ever exist, but the number mined will slow exponentially as the reward is continually halved. “By that point, enough people will be using the network that transaction fees alone are enough to incentivize miners to keep mining,” Smith explains.
(Top image via Flickr user davidd)