So, now let's talk about how Bitcoin blocks get put together. So we've been talking about the blockchain and the fact that transactions are actually grouped by blocks. But everything in this lecture so far, we've been talking about just individual transactions getting published. So why do we group transactions together into blocks? Well, a couple reasons. One is that that creates a nice, single unit of work for miners that's bigger that the individual transaction size. So if the miners had to do work and do hashing and add metadata for every transaction in the system, that would provide too much overhead. It also makes the hash chain of blocks shorter because we only need one block for a large number of transactions. And that's going to make it easier for us to verify the blockchain data structure. So what does the blockchain data structure look like? It's a pretty clever combination of two different hash-based data structures. So on the top here, we have a hash chain of blocks. Each one has a block header and then a pointer to some transaction data, as well as pointer to the previous block in the sequence. And remember these are hash pointers. And then we have a tree of all of the transactions that are included in each block. So this is a hash tree or what's called a Merkle tree. Which commits to all of the transactions in the block in quite an efficient way. So it's easy to provide just the path through the tree which will be logarithmic in size to prove that that transaction is included in a specific block. So that's the high level idea behind the block. What does it look like in practice at the low level? So we'll do another deep dive into the actual data here. So this is what a Bitcoin block looks like. There's what's called the block header which has all of the metadata for that block. And then there's that Merkel tree of transactions. So basically a long list of transactions. All of the hashes are arranged in this tree structure, which gives you the ability to efficiently prove which transactions are included in a block. The most important part, of course, is the header, which mostly has information related to the mining puzzle, which was talked about in the lecture on consensus. And we'll revisit in the lecture on mining. But recall that the most important thing here is that the hash of the block header has to start with a large number of zeros for the block to be valid. And then there's some other data to make that happen. There's a nonce that miners can change. There's a time stamp. There's an indication of how difficult this block was to find. That's all stored in the header. And the important thing is that the header is the only thing that's hashed during mining. So to verify that chain of blocks, all you need to do is look at the headers. And the only transaction data that's included in the header is that one route of the transaction tree. So that's this mrkl_root parameter. The other thing that's interesting about blocks is that they have one special transaction in the Merkle tree which is unlike all the other transactions we looked at before. And this is the coin-based transaction. So this is where the creation of new coins in Bitcoin happens. It mostly looks like a normal transaction with a few exceptions. So the value of this transaction is going to be equal to currently a little over 25 Bitcoins. As we discussed, this is a flat mining reward which is set by the system and which is halving every four years. In practice it will be a little bit more than 25 Bitcoin, because it also gets to include the transaction fees collected from every transaction included in the block. So the pointer to the output transaction that this coinbase transaction is receiving is a null pointer. It's a hash of all zeroes. And this is an indication that since this is the creation of new coins, there is no antecedent. There's no previous transaction that's being consumed to create these coins. And there's also this special coinbase parameter, and the coinbase parameter is completely arbitrary. The miners can put whatever they want in there. So, famously, in the very block ever mined in Bitcoin, the coinbase parameter had a quote from the newspaper. It had a quote from the Times of London describing a story involving the chancellor bailing out banks, which was both a political commentary on the motivation for starting Bitcoin, and served as a commitment that Bitcoin, the first block was obviously mined after this newspaper came out. But since then, miners are free to put whatever they want in the coinbase parameter. It's been used as a place to put some arbitrary data for different reasons. To signal support by miners for new features, but there's no actual limits on what miners can put in there. So with the block format and the transaction format that we described earlier, the best way to learn it is to just see for yourself. So there's a lot of websites that make this data accessible. This is a screenshot from blockchain.info which I found very helpful myself in understanding and exploring what's going on at a low level in Bitcoin. There are a lot of other websites that do a great job of making this information accessible. So you can look at the graph of transactions, see which transactions redeem which other transactions. Look for transactions with complicated scripts, even look at the block structure and see how blocks refer to other blocks. It's all available online, because again, the Bitcoin is a public data structure, so a lot of different people have put very pretty wrappers around this to explore it graphically.