Video - Bitcoin - Transaction Block Chains
The mechanics of a bitcoin transaction block chain, which is a construct that is generated by bitcoin miners and functions as a global ledger for recording and validating bitcoins. You could theoretically encounter strange situations like this if not all nodes could communicate with each other. However, once there are two "different" chains out there, (honest) bitcoin mining nodes will start building on top of the one with the most work put into it.
The various nodes in the Bitcoin ecosystem were going to sit there. They're going to receive information about this transaction. But they're also going to be getting information about a lot of other transactions that are taking place around the same time, okay. And what these nodes are going to start doing is they're going to work on incorporating this transaction record into really a ledger of all transactions that have ever taken place in the Bitcoin system. And so what happens is that each node basically starts off by taking all of the previously unincorporated transactions that they've ever received so that there can be all these transactions out there that have kind of happened within a given time window and so there's all these Bitcoin transactions kind of floating around.
And these nodes, these Bitcoin miners are as they're called are going to receive information about all of these different transactions and they're going to start working on incorporating those transactions, okay. And their first goal is to collate these transactions, okay, into what's known as a transaction block. So if you recall our ledger analogy, a single Bitcoin transaction essentially corresponds to a proposed entry in a ledger. In that capacity, a transaction block would basically correspond to her page in a ledger where you have multiple transactions that are listed in that page of the ledger.
And the goal, the Bitcoin miners goal is really essentially to take that page and get it added to the global ledger book, the global comprehensive ledger book, all right. Now, to engage in this sort of work what these nodes will basically do they'll first take all the transactions that have been broadcast and let's say these four transactions have been broadcast out, okay. And they're going to basically hash the transactions in pairs, okay and basically in a three like structures. So they'll take these two transactions and they'll apply cryptographic hash function to those details and they'll get a corresponding digest. Those are the same for these two and then they'll take these two digest and hash them to get a single digest value. And this digest effectively encodes all of the transactions that were previously unincorporated and that were received by these individual nodes, all right. And then this digest is basically going to be combined. It's going to be combined with the hash of the transaction block that was previously accepted by the network.
So you can imagine if there is, the network will have a series of transaction blocks that were previously accepted and in fact every transaction block as I mentioned just now incorporates the previous transaction block. So this transaction block will incorporate the one that was used just before it and this transactional block will incorporate the one that was used just for it and then it's going to go on literally into the beginning of Bitcoin times. This is really where the Bitcoin, the beginning of time for the Bitcoin system okay. This is just a time equals zero for Bitcoin, okay. And they're going to take this last block and they're going to essentially now take this last block and combine it with this most recent block.
And so if you imagine that you have now not just individual block but because each individual block incorporates the block before, we're not dealing anymore with an isolated or distinct block of transaction, but rather with a chain of blocks that starts literally at the beginning of the entire Bitcoin system, all right. Now, when you do all this combination at the end of the day, you're going to do some cryptographic hashing and you basically will end up with a sequence of numbers, okay. And the sequence of numbers will be derived by incorporating all these blocks together, and you'll get to sequence of numbers. And what we're going to basically do is take the sequence of numbers and convert that sequence of numbers into a challenge in a proof of work protocol, okay.
Now, I did a separate video on proof of work protocols. I would encourage you to watch that if you want to get a better sense for how they work. But the short of it is that what the Bitcoin mining node has to do at this point is he'll take the Bitcoin, he'll take the challenge and he'll have to come up with a separate sequence of numbers which we typically term to proof, for the proof of work. And this proof of work has have a very specific mathematical property. What that property entails is that if you take the challenge numbers and you take these proofs numbers and you concatenate them together and you make them the input to a cryptographic hash function, okay. The resulting output has to have a large prefix of zeros, okay. And there doesn't have to be all zeros but a large portion of the beginning, the prefix has to be all zeros, okay.
And if you think about it for a moment given the cryptographic hash functions, given that their output tends to look fairly random, it's unlikely that in any given instance you are going to see a proof, a proposed proofs that provides you with a large string of zeros at the beginning. And so what the Bitcoin miner will have to do is on average he'll have to try many possible choices for these proofs numbers until he finally gets lucky and he stumbles upon one that has this kind of offbeat or strange statistical property, okay. And the actual difficulty of finding these proof numbers as you can tell is dependent on exactly how many leading zeros are required, okay. The more leading zeros you require in this proof, the longer it takes to actually solve the problem. The longer it takes to actually come up with a proof that works with respect to a given challenge. The fewer zeros that you require, the less time it'll take.
Now, the exact number of bits of zero bits required in the Bitcoin protocol actually does change over time. It gets calibrated and it's designed on average. The average time taken across the whole system should be about 10 minutes, okay. So you wanted to take about 10 minutes for at least one node to come up with a valid proof but keep in mind that a lot of nodes are working on this proof concurrently, all right.
Now, once this proof of work is found, let's say that the proof of work is eventually found. The Bitcoin miner will announce the results to the overall peer to peer networks, he's going to take his proof and really all the challenge and so on and he's going to announce it to all the other nodes and they're now going to see that, hey, there's this proof out there, somebody found it, let's drop the other stuff we were doing and we're going to now start to work and build on top of this new proof. And remember this new proof and this new challenge, these all incorporate all the previous transaction blocks so really what they're starting to do is -- is they're starting to work off of a new updated transaction block chain, okay. And they're going to incorporate any new unincorporated transactions into that new Transaction Block Chain.
Now, there are a couple of points I want to make here. So first of all, as part of constructing this transaction blocks it really is part of incorporating them into a transaction block chain. Bitcoin miners are actually allowed one little special treat. They are allowed to include in that transaction block a special node for themselves and this node will basically be a little reward that they can get. And let me use the kind of a greenish color for that rewards. They can take the first block, the first transaction item, okay, the first transaction record. And they can put in that transaction record, they can assign a reward to themselves, okay. Now, the amount of that reward will change over time, okay but I do want to point out that what this transaction is typically called, it's called a coin base, a coin based transaction or a generation transaction. This is how new coins get included in the Bitcoin system.
So whenever a miner succeeds in coming up with a proof, as part of that he'll have been allowed to come up with his own transaction to reward himself, a special reward for expending the effort necessary to come up with this proof and for doing all of this work associated with adding a new transaction block to the existing transaction block chain for Bitcoin, all right. And I think that's reasonable after all these nodes are using a lot of computational power to come up with these proofs and that if they're using computational power that must mean that somewhere along the line somebody is spending money on electricity and so on.
Now, I also want to point out that in addition to this coin base award, the nodes who are doing the Bitcoin mining, the one's succeed, also get to collect the transaction fees that were specified in the transaction records. If you recall a person issuing a transaction in Bitcoin can allocate or set aside a certain amount of money, maybe it could be a Bitcoin or fractional Bitcoin for the node who succeeds in coming up with the actual proof of work and effectively the node that succeeds in being able to add that transaction to the overall Bitcoin transaction blockchain. And so that node that does the work succeeds gets a reward of a transaction fee.
Now, this could actually become quite large because the node will not only get the transaction fee for one transaction, will get the transaction fee for all the transactions that appeared in the current block. It's going to get the aggregate over all these different transactions, all right. Now, the second point I want to make is that it might be possible for two nodes to solve the proof of work independently of each other and somehow, they may both end up trying to add to that existing chain and in some way, so you may get some weird chain forking happening. Maybe if that happens the peers in the Bitcoin network will basically break a tie by sticking with the longest chain. And by longest, I don't mean the one that has the most transactions in it. I really mean the one that has the highest aggregate difficulty associated with that underlying proof of work protocol in each of the transaction blocks.
So they'll basically look at the total amount of effort that was required to generate that chain with regard to that proof of work and whichever chain has the most work associated with it, is a chain that sacrosanct, it's a chain that everybody will accept. Now, you may get somewhere discrepancies because of network latency issues and so on but the idea is that after maybe a couple of rounds when there are ties they'll quickly resolve themselves as long as most of the nodes are behaving honestly and really stick to their implementation of the protocol, all right. Now, since Bitcoin miners are generating Bitcoins I think there's an interesting question that comes up here which is, you know, how does a Bitcoin money supply controlled and how was it managed. And I'm going to talk about that concept in a subsequent video.