The following is a description of the global, statistical gamble which is played every 10 or so minutes. The interval of the game is controlled by the difficulty which says how many “hashes” are needed per interval.
In other words, the
target define the “odds of the house” against your chance of getting a winning SHA hash. The
nonce is the “scratch off” area.
Each hash consumes electricity, and emits heat, which requires additional cooling.
This is what is done with each hash:
At a high level, the miner software takes a list of active transactions, and then groups them together in something called a “block”.
Or more accurately stated: The miner software coverts all the transactions into a summary view called a “merkle root”, and hashes it, which is representative of the transactions.
Then mining software converts this to into a binary format called a Block Header, which also references the previous blocks (also called a chain).
Field Purpose Updated when... Size (Bytes) Version Block version number You upgrade the software and 4 it specifies a new version hashPrevBlock 256-bit hash of the previous A new block comes in 32 block header hashMerkleRoot 256-bit hash based on all A transaction is accepted 32 the transactions in the block Time Current timestamp as seconds Every few seconds 4 since 1970-01-01T00:00 UTC Bits Current target in compact format The difficulty is adjusted 4 Nonce 32-bit number (starts at 0) A hash is tried (increments) 4
The miner hardware changes a small portion of this block called a “nonce”.
The block header is hashed and compared to the Target as if it were simply a large number like 10,000,000 > 7,000,000 (the real numbers are much bigger, and in hex). The target is compressed and stored in each block in a field called bits.
An expanded target looks like this:
And the goal is to make sure the SHA256 hash of the block is less than this value. In the example below “
83ee” is smaller than “
To simplify this concept, you can ballpark the target by counting the leading zeros (as the other answer here explains). Here is an example:
Here is a sample block with transactions you can view on BlockChain.info. Look in the upper right hand corner of the webpage for this hash:
That previous hash was from today and has 14 leading zeroes. Let’s compare that to what was needed 3 years ago with block 100 which has 8 leading zeros.
So at the end of the day, all a miner does is:
- Take a block header as input
- Change the Nonce
- Test if the Block Header hash is less than the Target. If it is, you win.
- Go to step 2 (or go to step 1 if someone else won the block)
Want to see what Bitcoin-QT does when it finds a block?… I posted it here.. The information in this post will help you understand what happened.