One of the interesting features of Bitcoin is that bitcoins were not created and stashed someplace when the software was released. Instead, new bitcoins are created through a process called Bitcoin mining. And since anyone with a computer is capable of mining bitcoins, and creating money out of thin air, Bitcoin mining has attracted a lot of interest.
To mine bitcoins, special software is used that attempts to generate a new Block, which gets added to the Bitcoin Block Chain. The Block contains a list of recent, valid transactions on the Bitcoin network, and the Block Chain is a ledger every Block created since the Bitcoin network started.
Because the Block Chain is so important, adding a new block is not easy. To create a new block, a Bitcoin miner must show proof of work by generating a hash of the Block’s header. The Block’s header contains a summary of the contents of the Block.
A hash is a way to represent a lot of data in a compact, but unique, manner. Bitcoin uses the SHA-256 hashing algorithm, which produces a number that is 256 bits long. Usually the output is represented in hexadecimal format, and looks something like this:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
The SHA-256 hashing algorithm is very fast, but just producing the hash isn’t enough to create a new, valid Bitcoin block. The hash produced must be lower than the target threshold set by the Bitcoin network. The current target hash is:
00000000000002816E0000000000000000000000000000000000000000000000
If the hash produced by the Bitcoin miner is above the target, the miner has to try again. The miner modifies the Block’s header slightly (in a field called thenonce), and hashes the new header. The miner keeps trying variations of the header until a hash is found that is below the target, or another miner produces a new block before them.
A miner can attempt millions of hashing attempts very quickly, but each new attempt is essentially starting from scratch. There is no way to predict how modifying the Block’s nonce will affect the resulting hash in advance. Which means that, with every attempt, the miner is no closer to completing the work then when they started.
To make things even more difficult, the target threshold is adjusted every 2016 blocks (about every 2 weeks). The Bitcoin network wants a new Block to be created every 10 minutes, on average. If more miners join the network and start producing Blocks faster than that, the difficulty will be increased.
If a miner does produce a block, they’re rewarded with 25 bitcoins. The number of bitcoins awarded is cut in half every 4 years. Combined with the ongoing mining arms race, where miners are bringing on faster and faster hardware, the drop in award fee means that mining bitcoins is going to be harder, and less profitable, over time.
If you’re interested in getting started in Bitcoin mining, check out the next post.