There’s a scene in Neal Stephenson’s “The Baroque Cycle” in which the 17th Century English economy is described as almost completely run from lists of debts due to the lack of circulating coinage. Welcome to the wonderful world of Bitcoin!
There is no such thing as a bitcoin. When someone says “I own a bitcoin,” what they mean is “I know the code or codes that can authorize the transfer of up to one bitcoin.” If you buy a “loaded” physical token for 0.01 bitcoin on eBay, the token contains a code. Neither the token nor the code is “bitcoin,” but the code enables you to transfer amounts adding up to 0.01 bitcoin to other accounts.
Bitcoin’s foundation is a public transaction ledger called the blockchain. Every bitcoin transaction is recorded on the blockchain and anyone can inspect the transaction history going back to the creation of the first block of the chain. Because the blockchain is public, bitcoin transactions are not as anonymous as some people currently in prison had hoped. Every new account is anonymous, but that anonymity will probably be compromised by the first transfer of bitcoin into it because the bitcoins in the source account probably have a history–and there are companies whose business plan is to delve through the blockchain to link accounts to owners and sell the information.
Here’s how the blockchain works: people with codes that control bitcoin create transactions. Transactions can have one or more input accounts and one or more output accounts. Newly created transactions are sent to the cloud of computers running bitcoin protocol clients and added to a list of pending transactions. Anyone can download a bitcoin protocol client and run it on their computer, but running a full “node” takes a lot of disk storage space and Internet bandwidth.
Some of the computers running bitcoin protocol clients are “mining” bitcoin. To mine bitcoin, one selects transactions from the pending list and packs them together into a binary blob called a “block”. The block is then scanned to create a “hash” value. The last digit of a 16 digit credit card number is a hash value calculated from the first 15 digits. This is how web sites can automatically determine if you’ve mistyped a credit card number.
The hash value created by scanning a block isn’t a single digit. It’s 78 digits long, and it’s unlikely that the first hash value created for a block will “mine” the block because there’s a trick. The bitcoin protocol tries to make it so that a block is mined every 10 minutes. To do this, the protocol periodically adjusts the difficulty of mining by specifying a maximum value for the hash value. In addition to the selected transactions, the block contains a counter. When a block is first created, the counter value is zero. The block’s hash value is calculated. If the hash value is less than the current maximum value, then the block is “mined.” If the hash value is greater than the current maximum, then the counter is incremented and a new hash value is calculated. Subsequent hash values created by incrementing the counter are essentially random values from zero to 1.16×10^77. The process of mining a block is repeatedly incrementing the block’s counter and calculating the next hash value until the hash value is less than the current maximum value.
When a hash value is less than the maximum value, the winning block/counter/hash combination is sent to the cloud of computers running bitcoin protocol clients, and the block is added to the end of the blockchain. The transactions in the block are considered complete and removed from the pending list. All the miners start the process over again, create a new block from transactions in the pending list, and commence mining it.
As incentive to mine, the account of a miner who successfully mines a block is credited with (as of this writing) 12.5 bitcoins. This is how new bitcoins are created. The number of bitcoins created for each successfully mined block declines slowly over time. Miners can also keep any change left over from a transaction. If a transaction specifies an input account that contains one bitcoin and specifies the output account should get 0.99 bitcoin, then the remaining 0.01 bitcoin is kept by the miner. This is incentive for miners to include the transaction in their blocks.
Most mining is done by groups of miners who join together in a mining “pool.” A central computer creates the block which is sent to the members of the pool. Each member mines using a different initial value of the counter. If a pool member mines the block, the result is sent to the central computer and the pool members share the reward in proportion to their effort. Anyone can buy a mining rig on eBay and join a mining pool.
Bitcoin mining is almost exclusively done by specialized mining equipment, and the price of bitcoin is directly related to the cost of the electricity required to mine blocks. If the exchange value of bitcoin rises to the point where it’s very profitable to mine, then existing miners buy more equipment or new mining pools are created. This makes mining faster and blocks are mined more frequently than every 10 minutes. This makes the bitcoin protocol increase the mining difficulty by decreasing the maximum hash value. This means miners have to mine longer to mine a block using more electricity and reducing profits. Miners must sell some of their new bitcoins to pay for the electricity used, so the price of bitcoin is ultimately related to the cost of electricity.