Bitcoin's Blockchain Technology

What exactly is in there, and how does it work? See it for yourself, directly. Quick Start: Have a look at the 208-305-3068.

Bitcoin and it's blockchain are well documented online. This tool fills a gap by helping curious people see the data for themselves. It displays a block in it's entirety, with annotations to aid understanding.

Each of these other sites will help build a picture of what's in a block. They're all very useful.

None of them shows you the raw data though. If you're a developer, or someone else curious about the specifics, seeing the data can be invaluable. Here are some examples of actual Bitcoin blocks.

What you're seeing on those pages is a hexidecimal (hex) representation of the data in one block. Plus a little bit. We've included the 'magic number' that precedes each block in the feed. The blocks as they're stored are in binary, so showing them directly isn't practical. We've converted them to hex for readability. Every two characters you see represents one byte on the disk. Other than the conversion to hex, the large panel on the left shows exactly what is in a block. Segments are typically in big-endian order, meaning that they seem backwards to a reader. The (decimal) number 1000 is 03e8 in hex. It'll appear in the block as e803.

Similarly, if you look at the Block Size of the Genesis block, you'll see d7000000. That looks like a huge number, but it's in big-endian order. Reverse it (to 000000d7), and it looks more like what it really is: 215 decimal.

Each block has a header and a number of transactions. Each transaction has a number of inputs (Bitcoin coming in to be spent) and a number of outputs (Bitcoin going out).

We've hand picked a few blocks that may be of interest. The Genesis block is the first in the chain. You'll note that it's Previous Hash is all zeros, indicating that nothing came before. It has only one transaction: a reward of 50 Bitcoins for creating (mining) the block, presumably going to an address controlled by Satoshi Nakamoto.

The Pizza Block has two transactions: the Coinbase transaction rewarding the miner with 50 Bitcoins, and the transfer of 10,000 Bitcoins for the purchase of two pizzas. This is the first known transaction where Bitcoin was used to purchase physical goods.

How does it really work?

We've seen the block format. How does this format add up to a distributed ledger that allows exchange of value with both anonymity and security?

Let’s discuss the anonymity part first. You can send Bitcoins, or a portion of a Bitcoin, to another person without knowing who they are. Think of it as sending to an address, rather than to a person. That’s close enough to reality to be useful for now. The full story is hidden in the input and output scripts.

If you’ve sold five widgets over the internet, and taken payment in Bitcoin, you've probably followed the convention of using a different address for each transaction. Addresses look like this, 1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1, so keeping track becomes cumbersome quickly. You probably have software of some sort keeping track of your addresses and your balance. This software will also help you spend Bitcoin when it comes time to pay your suppliers or employees. You’ll have a ‘wallet’ controlled by this application, which includes all details, including the secret key needed to spend the contents.

It’s possible to send Bitcoin to any address you wish. You could send some to another address owned by yourself (and this is common), or to an address that isn’t actually used by anyone. The specific address shown earlier is from an early block, and is presumed to be controlled by the creator of Bitcoin. You could send to it, even though your contribution is unlikely to be claimed.

To send Bitcoin, you need 1) some of your own Bitcoin (attached to an address that you control), and 2) an address controlled by the intended recipient. The transaction is typically done through your wallet software: choose the destination address, and an amount, and your Bitcoin will go; the transaction will become part of the newest block in the Bitcoin blockchain.

Everyone working with Bitcoin has a record of the blockchain. That necessarily limits the anonymity of the system, but as long as no one knows your addresses, they can’t know your balances.

So, how is this secure?

If everyone has a copy of all the transactions, what’s to prevent someone from changing a value and claiming to have more than they really do? (Oh, if only the answer was simple human decency! But if that were true, you wouldn’t have thought of that question.) A small part of the answer is the obvious: everyone has a copy of all the transactions, and a fake could be spotted. To prevent arguments, fights and lawsuits from breaking out all over, the system makes clever use of cryptography.

Specifically, the system uses a number of hashes to enable detection of trickery. If you ‘hash’ some text, you get a representation of that text that looks completely different. Hashing ‘groktheblock’ gives the hash e22cb760118c7bff73bcf868661343e36f4581a07685548686959b1023ed996f. Add a small change, ’Groktheblock', and we get de9ae0eb4d66e119a5dd2da62058032e6f2b6b5642d218b9c7acc835f550939c: a completely different result. It’s easy to know if the original text has been changed, if we have a copy of the original hash.

Bitcoin hashes the header of each block (Version through Nonce), and stores the result in the next block in the chain. Its in the ‘Previous Hash’ field. So, if anyone changes part of a block’s header, it will be obvious because it’s hash will no longer match the value in the next block.

That in itself is insufficient. We need to detect changes in the transactions more than we do the block header. Of course, we can. Part of the header is the ‘Merkle Root’. This is the root hash of a Merkle tree. Merkle trees are interesting in themselves, but essentially the root is the result of hashing each of the transactions. If one of the transactions is changed, we’d know, because the Merkle Root wouldn’t match.

So, the next block in the chain contains proof that the current block’s header hasn’t been faked. The current block’s header has the Merkle Root, which proves none of the block’s transactions have been faked.

Magic Number Block Contents
Block Size
Version
Previous Hash
Merkle Root
Time Stamp
Difficulty Target
Nonce
Number of Transactions
Version Number
Number of Inputs
Transaction Hash
Index
Script Length
Script
Sequence Number
Number of Outputs
Value
Script Length
Script
Lock Time