Anatomy of a Bitcoin Block
Art is interpreted in the eyes of the beholder. A string of hexadecimal digits is not commonly viewed as art, but I will make my case for how Bitcoin is beautiful art. In 2009, Satoshi Nakamoto released his famous Bitcoin whitepaper. Bitcoin has since been worked on by thousands of developers and finds itself in popular mainstream news stories. In this article, I am going to be breaking down the art that is bitcoin.
Before breaking down what is in a bitcoin block, I need to explain what it is. The underlying technology that Bitcoin uses is blockchain. Blockchain is a data structure that stores data (transactions in Bitcoin’s case) in chronological order into a block of data to be linked to the next block. In Bitcoin’s case, a block is added every ten minutes containing all of the transactions broadcasted in that time period. The resulting block looks like this:
Isn’t it beautiful art? What you are looking at is the binary 1’s and 0’s that are stored in the bitcoin block. Contained in these blocks is all Bitcoin being moved on exchanges, companies buying or moving Bitcoin, and even the purchase you made at a store with Bitcoin. All in less than 2 megabytes of data!
This is the version of bitcoin in the block. It is important for bitcoin nodes to know the specific version of bitcoin for validation. This is the first block so the version is 1.0.0.
Previous block hash
Bitcoin relies heavily on hashing algorithms to be able to validate transactions. This means that given an input or transaction, the data is encoded into a 256 bit string. In this section of the block is the previous block hash. Usually this section contains hex information but because it is the first block it has nothing previous to reference. For the blocks to be connected they must have a reference to the previous block. Hence the name blockchain. It is just a linked list of blocks referenced by the previous computed block hash.
Merkle root of transactions
This is where the art starts to take place. This section contains every single transaction that has transpired over the block’s 10 minutes. The merkle root also uses a hashing algorithm to bring together every transaction into one hash. To explain further, say we have four transactions: A, B, C, and D. To calculate the merkle root, you hash A and B together to produce hash E. Then, you hash C and D together and receive a hash F. Now we have two hashes E and F. Hash E contains transaction A and B hashed together and the same for F with C and D. To calculate the final merkle root you would hash E and F together to get the final merkle root hash. This is simplified of course, a bitcoin block could have thousands of transactions!
Pretty self explanatory. The time the block was produced and broadcasted to the network. January 8, 2009 at 9:54pm in this case (the birth of Bitcoin).
To have a block broadcasted on the network every ten minutes is a difficult task to do. Without going into specifics, blocks are verified through a consensus algorithm know as Proof of Work. This means that nodes in the bitcoin network are competing to verify a block through computational work. As more nodes are competing in the network it will cause the block times to be produced in shorter time. Satoshi Nakamoto, our artist, got around this by making the computational work harder by introducing difficulty adjustments. This keeps the block times consistently around ten minutes regardless of the strength of the network.
This is the number that miners are trying to guess to produce a block. When nodes are competing in computational work, this is the number that when guessed correctly adds a block to the network. The miner that guesses the nonce is also rewarded bitcoin for their work. This is how new bitcoins are minted.
The nonce is the last part of the block header. Following the header is the block body. The block body contains all of the inputs and outputs from transactions. The block body is a very complex operation that could have its own article. If you would like to have an article on the anatomy of the block body leave a comment!
I hope this gives you a higher level understanding how all of bitcoins code comes together in one block. The work of Satoshi Nakamoto and the Bitcoin development team goes unnoticed I believe. Art is subjective, but when thinking of the engineering behind Bitcoin I can’t help but look at it as beautiful art.