Skip to content

How Does Blockchain Work?

How Does Blockchain Work?

We will go a bit deeper into the inner workings of blockchain technology. We’ll be covering what blocks are, what a blockchain wallet is, along with block times, consensus algorithms, and mining.

Back to the Spreadsheet Analogy and Bitcoin

An online spreadsheet gives access to a single document to everyone in your team. The data in that online spreadsheet is shared to all members of your group. Everyone can add data and information, everyone can add formulas, and everyone is allowed to edit the numbers after they have been added.

As long as you have permission from the person who shared the spreadsheet document, you are free to add and edit information as needed. Everyone in your team can check and audit your work and look for errors if any.

That is not the case with a blockchain. The big difference between a blockchain and an online spreadsheet, is that you can add to the data but you can’t edit information once it is already recorded.

This function is called immutability. This is an important feature of blockchain technology and we will go back to that in detail later on. Just remember for now that over time, once data has already been entered into a blockchain, it can no longer be edited or removed.

Blockchain vs. Online Spreadsheet

Another key difference of a blockchain and an online spreadsheet is called consensus. There is a certain degree of consensus within an online spreadsheet but it is not as pronounced as it is on a blockchain.

In a spreadsheet, other users can audit your data. Everyone can see what you are doing and they can also make changes to your work in case they see that you have made mistakes. In other words, other users must agree that what you have written or computed is correct and accurate.

However, the problem is that the other users will have to wait for you to add your numbers first before they can decide whether it should be included in the sheet or not.

Now, when the principle of consensus and immutability is applied to spreadsheet, here is what will happen. If one of your team members would like to add information or a new cell to your spreadsheet, the rest of the team will have to approve of that change or addition first.

It will require a majority vote from all of those that have access to that online spreadsheet before that new cell can be added. After a consensus is achieved then the new cell will be added to the main spreadsheet.

Back to the Bitcoin

To understand how blockchain technology works we will need to explain how bitcoin works. It is the first successful blockchain implementation so it will make sense to start from there. That way we will get a firsthand look into the inner workings of a blockchain and how it is applied today.

Satoshi Nakamoto launched the bitcoin blockchain when he initiated the creation of block zero. As a result of that launch, he was awarded by the blockchain system with 50 bitcoins.

What he essentially did was he mined for the first bitcoin block. It is the very first block in the chain of blocks that will be called the bitcoin cryptocurrency. The next question is how are new blocks added or how are new transactions added to the very first block that Satoshi Nakamoto san created?

Adding Transactions

Let’s say Satoshi added new people to the peer to peer network that he started. Let’s call one of them as Bob—we don’t really know if there was a Bob, I’m just using a theoretical example and it doesn’t refer to real person, in other words this is a fictitious example that is aimed at illustrating how new transactions and new blocks are added to a blockchain.

So, again, let’s go back to Bob. So, maybe Satoshi ordered a premium cup of coffee from Bob. Satoshi suggested that he would like to pay Bob with the new cryptocurrency that he created, bitcoin.

Bob agreed seeing the novelty and value of this new digital currency. So, Satoshi added Bob to the network through an app and Bob was given access to the peer to peer network through that app.

Bob’s Bitcoin Wallet

Note that Bob’s bitcoin is stored in something called a bitcoin wallet (or cryptocurrency wallet). This wallet can be an app, an electronic storage, your phone, or even just a piece of paper.

A bitcoin wallet is essentially just a document that contains information about how much bitcoins you actually have. It contains a unique public address that you are using to receive bitcoins and a private key that secures your wallet.

Think of it as a PayPal email. You can use that email as your address to log into your PayPal account. You then use that account to receive payments and also to make online purchases. You can reveal your PayPal email to the public so they can send you funds.

But you don’t want to reveal the password to your PayPal account. If you do, then others can get to your account and steal your funds. The same thing works with a bitcoin wallet. You give your wallet’s address to interested parties so they can send you bitcoin but you keep the crypto key that serves as your secure access to that account and your funds.

The Transaction Continues

Satoshi then transferred 1 bitcoin to Bob’s account. This transaction or transfer of one bitcoin from Satoshi to Bob will be recorded on the bitcoin ledger. If Bob and Satoshi would look at the current records stored in the ledgers of the blockchain, they will see this very first transaction recorded there.

The ledger will record where the bitcoin came from (i.e. Satoshi’s stash—pun intended). It will also record which account the bitcoin was transferred to (i.e. Bob’s account). The account numbers (i.e. bitcoin addresses) will be encrypted, so no one else will know who the actual owners of the said accounts are.

If there are further transfers of bitcoins from one owner to the other (i.e. from one account to the other), then it will be recorded in the ledgers of the blockchain.

And Now Enters the Bitcoin Miners

You can’t just add records at will or else the entire system will be chaotic. Everyone “firing at will” as it were can result to mistakes in the record and the system will fail. On top of that, you should remember that the ledgers in a blockchain are immutable. Once you have entered information in a ledger, you can’t change it. All you can do after that is to say “whoops!”

There must be a safeguard or a way to verify that transactions made and records added to the ledgers in a blockchain are true and correct. In other words there must be a way to validate each transaction. That is the job for bitcoin miners.

If there are other transactions that also occur in the same time frame, then that record is also grouped together with other transactions that have also transpired within a designated time frame.

These ledger inputs are then stored in a protected block. The protection comes in the form of a mathematical encryption. Once the transactions have been recorded in the ledgers (i.e. recorded in the block, they can’t be altered.

Before a transaction can be recorded, there is a validation process that will happen first. Now enter bitcoin miners—these are special computers that solve mathematical problems. What they are doing is that they are solving problems for the block, which serve as a layer of protection so you can’t add transactions at will without any check and balance.

There are a lot of miners on the peer to peer network. The first miner that will be able to solve the mathematical problem produced by the network will provide the validation needed so that the new record can be added to the blockchain.

The system then rewards that bitcoin miner with a 1 new bitcoin. Sometimes it is just a fraction of a bitcoin or some other kind of cryptocurrency. And that is the only way that a new coin can be created in a bitcoin blockchain.

Take note also that there is a predetermined total number of bitcoins that will ever be created. This creates a scarcity, which will drive the value of bitcoins as the supply gets lower and lower.

After the validation process is completed, the new block, along with the other transactions that have been grouped with it, will be added to the blockchain. Again, it is important to stress that once all of this computing, validation, and recording has been completed, there is no way to edit what has been recorded.

You will be faced with the monumental task of breaking encrypted code and other built in security features of a blockchain. So, why make transaction records immutable? Well, it solves a problem called double spend.

Solving the Double Spending Problem

Double spending means using the same bitcoin to make repeated purchases. Think of it this way, you can create multiple copies of your mp3 files, right? If your baby brother wants a copy of that nursery rhyme mp3 on your hard drive, you can just copy it and send it to his iPad online or through Bluetooth or some other means.

But what if you have a friend who also wants a copy but you don’t want to give him one? He then offers to trade a signature shirt for that mp3 and then you agree to this trade. So you send him a copy and he gives you that shirt.

What happened here is that you technically “spent” your copy of the mp3 file twice. You technically gave it to your little brother for free and to your friend for a price. You have just made a double spend.

That is the problem that we have with digital products. They can be easily copied and replicated. And thus if we allow digital currency to be copied without end then there is no scarcity and the value of these currencies will be next to nothing since anyone can just make a copy and use it to buy stuff.

Bitcoin and cryptocurrencies (and all other types of blockchains for that matter) have solved that problem. The solution is to provide that confirmation or validation mechanism using miners.

The bitcoin blockchain also makes sure that the blocks that have been validated are stored in chronological order following a series of time stamped. If you look at the data of a current block it will have a record of the block address (i.e. the identifier or a unique ID) of the block previous to it and the block that comes after it.

To ensure that the order of the chain of blocks is correct, the address of the blocks should be in the correct order and with the correct time stamp. In the case of the bitcoin blockchain, the time stamp record begins in 2009.

These are added security features so that no one can just add a block in between the chain. If you tried to do that, then the ordered series and time stamps will no longer coincide and an error would occur.

Take note also that in the bitcoin blockchain, a block is added to the chain every 10 minutes. After that, a copy of the entire blockchain is sent to all members of the peer to peer network (also known as the global ledger).

The Workings and Function of a Consensus Algorithm

So let’s say other people have been added to the peer to peer network that uses the bitcoin blockchain. Again, this is all theoretical and the names we will use below aren’t real people who took part in any way.

Each member or participant in the peer to peer network (or blockchain network) is called a node. Let’s say Frank already owns 5 bitcoins and he transfers 1 bitcoin to Bob as a payment for a cup of coffee, this transaction will be recorded in a new block along with other transactions that have occurred within a given time frame—again, if you were paying attention, that time frame will be about 10 minutes, but it will be different with each type of blockchain. 10 minutes isn’t a standard rule here—but it is the time frame that is used in the bitcoin blockchain.

Take note that all nodes will operate independently on their own accord. In other words, you (i.e. the node), can do as you please with your bitcoins. However, since you are part of the network, you will need to help verify that the records are correct using your copy of the main ledger.

There is a consensus rule in the peer to peer network of a blockchain. These rules are agreed upon by the community of users. If there are any changes that need to be made, then you will have to vote on it. In some cases a 95% consensus approval is needed before any change is made. This consensus makes it difficult to change any feature of the blockchain software.

Note however that the consensus algorithms will vary from one blockchain to another. When a node makes a transaction and it is validated by the bitcoin miners, then that new block or record is added to the blockchain and this updated copy is sent to all nodes in the network. Everyone else will then have to verify the values and then update their copies of the changes that have been made.

As you can see, nodes (that is the accounts that participate in the peer to peer network) do not mine bitcoin. In the peer to peer network of a blockchain, a miner will be a separate and special node. However, remember that both miner and non-miner nodes will be taking part in the validation of transactions.

Bitcoin Mining and Hash Algorithms

Now we have a bit of a clear understanding as to how blocks or records are added to a blockchain. We have also described how each block is validated first before it is added to the record, which solves the problem of double spending. These mathematical security features ensure that each bitcoin is unique (or a fraction thereof—yes,  you can trade using just a fraction of a bitcoin, think of it as dealing with dollars and cents).

The mathematical puzzle or problem that a bitcoin miner must solve is created using cryptography and will take some time to solve even for a powerful computer. This protocol or procedure of mining is called proof of work. Before a transaction can be validated a proof of work, which is quite difficult to perform, must be generated.

This proof of work protocol is a layer of protection from any kind of hacking that can be performed by any single individual or group. In the case of the bitcoin blockchain, it uses the Secure Hash Algorithm 256 bit or SHA-256, which is very formidable making the that blockchain virtually hack proof.

The output that is generated by miners is called a hash. The process of generating a hash is used to solve a mathematical problem that has an end value that is expected in the algorithm.

It takes thousands of tries for a bitcoin miner to solve the cryptologic problem necessary to produce the next hash (i.e. to validate a transaction). For instance, just to solve for the value “000” (i.e. three zeroes), it will take a bitcoin miner more than 6,500 tries. On top of that, this single miner will have to compete with hundreds if not thousands of other miners in the network.

The first miner that is able to solve the current mathematical problem will broadcast the answer to the entire network and will be rewarded with a corresponding bitcoin. If you are a hacker, then you will have to solve for that crypto problem too and you will also need to compete with other machines as well. The odds are slim that you can hack into the system with that huge a legal competition with a given time constraint.

Validation Difficulty

1 standard bitcoin blockchain today will require millions of hashes or millions of tries to solve. Remember that the huge majority of bitcoins have been mined since 2009. On top of that the complexity of each mathematical puzzle will change every time 2,016 blocks have been added to the current chain.

This method ensures that it takes 10 minutes for a new block to be validated and confirmed. If it takes longer to solve these math problems it is possible that they will be made simpler. However, since the goal is to add security to the network, then the 10 minute interval is maintained. That means the math problems or puzzles tend to get more complex over time.

About a decade ago, your home computer or laptop could have solved these crypto problems within the given time frame. However, fast track 10 years into the future, that isn’t possible any longer. The math puzzles are just now too complex and your run off the mill consumer level computer won’t make the 10 minute mark to solve the said problem.

It’s not that easy to validate a transaction anymore and consequently earn your next bitcoin. Today, computer manufacturers have introduced ASIC chips or application-specific integrated circuit. These were especially designed for mining bitcoin and other cryptocurrencies. However, do take note that these chips are incredibly expensive and nowadays there are only a select group of dedicated miners owned by people who can afford these machines.

Chronological Order and Immutability

Another important feature that we need to understand about miners and the bitcoin blockchain is the fact that each block has a unique ID, which is the hash that was used to validate that block. When a new block is created the hash or unique ID of the previous block is encoded to it and this hash is followed by the new hash that was generated to validate the current block.

This ensures that all the blocks will be organized in a chronological order. That means you can’t switch block 55 with block 54. You can’t even add a new block in between the series of blocks without the need to replace all the hash IDs that have been encoded in the following blocks. This system ensures that the order of the blocks will never be altered.

The Need for Scarcity

Scarcity is a feature of all types of currency. Remember inflation? Yes, it also applies to cryptocurrency. The law of supply and demand also works here. If there a huge supply of bitcoins, for example, then their value will decline.

The scarcity of a cryptocurrency will vary one from the other. Note that scarcity may not be a feature of other types of blockchain especially those that are not used for cryptocurrency. In such instances, the value of the blockchain is not dictated by a limited supply.

In the case of the bitcoin blockchain, it was predetermined by Satoshi Nakamoto that there will only be a total of 21 million bitcoins that will ever be created. It is estimated that this maximum number of bitcoins will be produced by the year 2040.

We mentioned that a miner can be rewarded with 1 bitcoin or a fraction of a bitcoin every time it is able to solve a hash problem or mathematical puzzle. Take note that it is not always 1 bitcoin that is awarded.

The way the bitcoin blockchain was coded, the amount of bitcoin that will be awarded to a miner will be split in half after 210,000 blocks have been added to the blockchain. Nowadays, you don’t get 1 bitcoin for every successful validation your bitcoin miner can come up with. It will now be just a fraction of a bitcoin.

It is estimated that the reward will be split until the twenty-one millionth bitcoin has been created. By that time, the last bitcoin would have been created. So, when that happens, what reward will bitcoin miners receive for validating transactions? By year 2040, bitcoin miners will be awarded transaction fees for each validation.

nv-author-image

Era Innovator

Era Innovator is a growing Technical Information Provider and a Web and App development company in India that offers clients ceaseless experience. Here you can find all the latest Tech related content which will help you in your daily needs.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.