Home / Markets News & Opinions / Bitcoin for Mere Mortals: Blocks

Bitcoin for Mere Mortals: Blocks

Last Updated
Alex Gorale
Last Updated

bitcoin blockchainBlocks are the data structures Bitcoin uses to permanently record data. This is common knowledge known by the initiated and in previous articles we’ve covered information related to these data structures. The block chain, isn’t really a chain at all. Well, logically there is a chain but it might not be what you first expect.

This article breaks down the structure of a block and provides insight to the moving parts “under the hood.” Hopefully, by the end, some of the underlying technology is to understand.

Bitcoin for Mere Mortals: Block Structure

Bitcoin for Mere Mortals: Block

That’s a block. In this image each cell represents one byte.

Magic Number
Bitcoin uses magic numbers to identify its network. Every Bitcoin-based cryptocurrency uses a magic number but the concept is not unique to Bitcoin. Magic numbers are used many ways and date back to the 70’s. In Unix, magic numbers were used to indicate format.

Where did it come from? In the source code we find:

// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ascii, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };

Blocksize
Four bytes used to declare how large (in bytes) the block is. Currently this is capped at 1MB but the maximum 32 bit number is around 2 gigabytes.

Bitcoin for Mere Mortals: Block Header

Version
The version of your Bitcoin software. We all should probably upgrade

Previous Block Hash
This is just a number. However, this is where the logic of the ‘chain’ comes in to play. Because each new block contains the hash of block that came before it they are linked, mathematically. Since the hash is like a signature, unique to the block, it guarantees the blocks are sequential. Furthermore, the linkage creates structure, like a one-way linked list.

Block Hash
The current blocks hash. This is the value all the Bitcoin miner’s are trying to find. The first 8 bytes must be a lower number than the target, or it is not a valid block hash.

It’s important to note that this isn’t *set* in the sense that there is only one valid Block Hash every miner is searching for. Miner’s are searching for any hash that falls within a range of numbers defined by the target.

Time
Current Timestamp in seconds since the Unix Epoch Time. (1970-01-01T00:00 UTC)

Mining is a loop in which the miner’s hardware makes a ‘guess’ – we call it a hash. With each guess the miner may update their Time value. However Bitcoin rejects blocks with time values greater than two hours away from the network time.

Target
Bits representing the current difficulty.

Nonce
An incrementing value. The nonce is important in cryptography and for proof of work. There will be a future article describing how Proof of Work operates.

That’s it for the block header

Bitcoin for Mere Mortals: Transaction Lists

A ::gasp:: list, of… wait for it… these:

Bitcoin Transaction

Transaction Counter
How many transactions are included with the block

Transactions have been covered in another article. However, this is also a list that provides previous Bitcoin transactions owed to you as inputs and declares the new controller of those bitcoins with outputs.

Version
Version of the user’s software

In/Out Counter
Count of the inputs and outputs included in the transaction

List of Inputs/Outputs
Where the transfer of control over bitcoins actually takes place.

Lock Time
4 bytes representing a block height that must be achieved before this transaction can be mined. Does not guarantee the inputs will be unclaimed by the time that height is reached.

Bitcoin for Mere Mortals: The Genesis Block

The Genesis Block is the first block of the block chain.

01000000 - version
0000000000000000000000000000000000000000000000000000000000000000 - prev block
3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A - merkle root
29AB5F49 - timestamp
FFFF001D - bits
1DAC2B7C - nonce
01 - number of transactions
01000000 - version
01 - input
0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF - prev output
4D - script length
04FFFF001D0104455468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73 - scriptsig
FFFFFFFF - sequence
01 - outputs
00F2052A01000000 - 50 BTC
43 - pk_script length
4104678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5FAC - pk_script
00000000 - lock time

By now, most of this should make sense. If not, there is always Tim Draper’s Bitcoin Course.

Bitcoin for Mere Mortals: The Block Chain

BlockChain Structure

When a block is accepted as valid it naturally continues the chain since it is required to reference the previous block.

What do you think? Comment below!

Images from Shutterstock.