How does blockchain work? Everything there is to know

Blockchain technology has become a common term across the globe, although understanding how it works can take some research. This article explains the technology and gives an overview of its ins and outs.

So, how does the blockchain work? A blockchain is essentially a digital diary that is almost impossible to forge. Numerous computers and devices contribute to this diary, removing a central point of failure. 

Blockchains are typically composed of many network participants — computers or hardware setups working continuously. Often dispersed across the globe, these participants each carry a copy of a blockchain’s entire transaction history and validate any new transactions as genuine, based on that history. 

These participants continuously compete to earn rewards for producing new assets, as well as facilitating transactions. To help explain this concept a little more simply, check out the hypothetical example below.

Hash function

Let’s imagine that 10 people in one room decided to make a new currency. They have to follow the flow of funds to ensure the validity of the coins in their new monetary ecosystem. One person — let’s call him Bob — decided to keep a list of all actions in a diary. However, another person — let’s call him Jack — decided to steal money. To hide this, he changed the entries in the diary.

Then one day, Bob noticed that someone had interfered with his diary. He decided to change the format of his diary to prevent future tampering. He used a program called a hash function that turns text into a set of numbers and letters, as shown in the table below.

This process harnesses a secure hash algorithm, or SHA, that turns the letters into character strings. Bob can choose different types of SHAs that each varies in complexity and serves different needs.

A hash is a string of numbers and letters, produced by hash functions. A hash function is a mathematical function that converts a variable number of characters into a string with a fixed number of characters. 

Just a small alteration in a string creates a completely new hash. After each diary entry, Bob inserted a hash. But then Jack decided to change entries again. He got to the diary, changed the record and generated a new hash.

Bob noticed that somebody had sifted through the diary again. He decided to complicate the record of each transaction. After each record, he inserted a new hash generated from the recorded last hash. Therefore, each entry depends on the previous.

If Jack tries to change the record, he will have to change the hash in all previous entries. Jack, however, was a determined thief, so he spent the entire night counting all the hashes.

Bob did not want to give up, so he added a different, random number after each record. This number is called a “nonce.” Nonces should be chosen in a way that results in the generated hash ending in two zeros.

In order to forge records with Bob’s updated entry system, Jack would now have to spend hours and hours determining the nonce for each line.

Nonces are difficult for even computers to figure out, but the task is possible, as miners compete to discover them as part of the blockchain mining process. 

Nodes

Bob kept up the diary in this manner for a short time. As new transactions continued occurring, however, he soon became burdened by the number of records, seeing his current system as unsustainable. So, as soon as his diary hit 5,000 transactions, he converted it to a one-page spreadsheet. Mary checked the accuracy of all transactions.

Bob then gave his spreadsheet diary to 3,000 different computers, each located in different regions globally. These computers are called nodes. Every time a transaction occurs, it must be approved by those nodes, each of which checks the transaction’s validity. Once every node has checked a transaction, essentially a type of electronic vote occurs. Some nodes may think the transaction is valid, while others may see it as fraudulent. 

Each node has a copy of the spreadsheet diary. Each node checks the validity of each transaction. If a majority of nodes say that a transaction is valid, then it is written into a block.

Now, if Jack wants to change one entry in the spreadsheet diary, all the other computers will have the original hash. They would not allow the change to occur.

Block

Bob’s initial spreadsheet of 5,000 transactions is called the genesis block — the starting point for this blockchain. Adoption of this currency has spread, so transactions come quickly and often. New blocks are created, which can also hold up to 5,000 transactions and have codes that correlate with former blocks, making them unforgeable. 

Let’s assume that this blockchain updates itself every 10 minutes with a new block. It does so automatically. No master or central computer instructs the computers to do this.

As soon as the spreadsheet or ledger or registry is updated, it can no longer be changed. Thus, it’s impossible to forge it. You can only add new entries to it. The registry is updated on all computers on the network at the same time. Changes to blockchains require consensus from a majority of the network’s participants. One potential risk to a blockchain is a “51% attack,” during which a party overtakes the majority of a blockchain’s hash rate, allowing them to then dictate the network.

In general, a block contains a timestamp, a reference to the previous block, the transactions and the computational problem that had to be solved before the block went on the blockchain. The distributed network of nodes that must reach consensus makes fraud almost impossible within the blockchain.

Wallets, digital signatures and protocols

Continuing with the same example, Bob gathered the 10 people together (the 10 people initially gathered that are part of the new currency). He needed to explain the new digital coin and ledger system to them.

Jack confessed his sins to the group and apologized. To prove his sincerity, he gave Ann and Mary their coins back.

With all that sorted, Bob explained why this could never happen again. He decided to implement something called a digital signature to confirm every transaction. But first, he gave everyone a wallet.

What is a wallet?

If you possess digital money, then you need a digital wallet or an online platform or exchange for storage.

A wallet is a string of numbers and letters, such as: 18c177926650e5550973303c300e136f22673b74. This is an address that will appear in various blocks within the blockchain as transactions take place. No names or personally identifiable information is included — just the wallet number. 

Public wallet addresses are strings of characters to which certain assets can be sent. The address of each particular wallet is generated from a public key.

Related: Bitcoin wallets for beginners: Everything you need to know

Digital signature

To carry out a transaction, you need two things: a wallet, which is basically an address, and a private key. The private key is a string of random numbers. Unlike the address, however, the private key must be kept secret. A private key controls funds held within its related wallet.

When someone decides to send coins to anyone else, they must use their private key to sign the message containing the transaction. The system of two keys — a private and a public key — is at the heart of encryption and cryptography, and its use long predates the existence of blockchain. It was first proposed in the 1970s.

Once the message is sent, it is broadcast to the blockchain network. The network of nodes then works on the message to make sure that the transaction it contains is valid. If it confirms the validity, the transaction is placed in a block. After that, no information about it can be changed.

What are cryptographic keys?

A cryptographic key is a string of numbers and letters. Cryptographic keys are made by key generators, or keygens. These keygens use very advanced mathematics involving prime numbers to create keys. Such keys can be used for encrypting or decrypting information. 

Protocols

The blockchain technology consists of individual behavior specifications, a large set of rules that are programmed into it. Those specifications are called protocols. The implementation of specific protocols essentially makes blockchain what it is — a distributed, peer-to-peer, secured information database.

Blockchain protocols ensure that the network runs the way it was intended to by its creators, even though it’s completely autonomous and isn’t controlled by anyone. Here are some examples of protocols implemented in blockchains:

  • Input information for every hash number has to include the previous block’s hash number.
  • The reward for successfully mining a block decreases by half after 210,000 blocks have been mined. For Bitcoin (BTC), this is called halving. At 10 minutes per block, mining 210,000 blocks takes about four years, hence Bitcoin’s halving event every four years.
  • In order to keep the amount of time needed to mine one block at approximately 10 minutes, mining difficulty is recalculated every 2,016 blocks. Mining difficulty essentially balances the network to account for the number of miners. More miners mean a more competitive atmosphere, making blocks more difficult to mine. Fewer miners mean it’s comparatively easier to mine blocks, thus enticing miners to participate.

Proof-of-work

The placing of a transaction in a block is called a successful conclusion to a proof-of-work (PoW) challenge and is carried out by special nodes called miners.

PoW is a system that requires some work from the service requester, usually meaning processing time by a computer. Producing a PoW is a random process with low probability, so normally, a lot of trial and error is required for a valid PoW to be generated. When it comes to Bitcoin, the hash is what serves as a PoW.

What is mining?

Miners on a blockchain are nodes that produce blocks by solving proof-of-work problems. If a miner produces a block that is approved by an electronic consensus of nodes, the miner is rewarded with a specific number of coins, called a block reward.

This block reward is not the only incentive for miners to keep running their hardware, however. They also generally receive transaction fees that users pay to send transactions. Transaction fees can vary depending on the number of transactions being sent on the entire network at any given time. More network traffic can mean higher fees. Even though fee amounts can be chosen by the sender in most cases, miners will always prioritize transfers with higher transaction fees. Therefore, unless you are willing to pay a rather hefty fee, your transaction might take a long time to be processed if network traffic is bloated. 

Read more in the article “How to mine Bitcoin?”

What is staking?

Blockchain technology can also function based on a proof-of-stake, or PoS, consensus algorithm. With PoS, stakers help run the blockchain by holding a blockchain’s specific asset in a staking-compatible wallet or location, receiving rewards for doing so. Network contribution depends on the amount of the related asset someone holds. This type of ecosystem does not mine blocks but forges them, as per industry terminology. 

Masternodes also exist in the PoS world to help run the network for specified rewards, although masternodes typically require a certain amount of a given asset and must be set up a certain way. Over the years, arguments have pitted PoS against PoW, with rationales made for one over the other.

Principles of the blockchain technology

Blockchains are essentially types of distributed databases. The database is the blockchain, and each node on a blockchain has access to the whole chain. No one node or computer regulates the information it contains. Every node is able to validate the records of the blockchain. This is all done without one or several intermediaries in control of everything.

It is architecturally decentralized, and there is no single point of failure that would bring down the blockchain.

However, the nodes of a blockchain are logically centralized, as the entire blockchain is a distributed network performing certain programmed actions.

Peer-to-peer transmission

In decentralized peer-to-peer (P2P) transmission, communication always occurs directly between peers rather than through a central node. Information about what is happening on the blockchain is stored on each node then passed to adjacent nodes. In this way, information spreads through the whole network.

Transparent yet pseudonymous

Anyone inspecting the blockchain is capable of seeing every transaction and its hash value. Someone using the blockchain is able to act pseudonymously if they wish, or they can give their identification to others. All that is seen on the blockchain is a record of transactions between wallet addresses.

Once a transaction is recorded on the blockchain and the blockchain updates, altering the record of this transaction becomes impossible. Why? That particular transaction record is linked to the record of every preceding one, making it immutable. Blockchain records are permanent, they are ordered chronologically, and they are available to all other nodes.

It is nearly impossible to turn off the network. As numerous nodes exist and operate globally, it is virtually impossible for a single party to take over the entire network. 

Faking a block is also nearly impossible because the validity of each block and, by extension, its inclusion into the blockchain is determined by an electronic consensus of nodes. There are thousands of these nodes, scattered all over the world. As a result, capturing the network would require a computer with a virtually impossible amount of power.

Using blockchain technology as a normal database would prove difficult, however. Can you store three gigabytes of files on the blockchain in the same way as using database platforms such as Microsoft Access, FileMaker or MySQL? This would not be a good idea. Most blockchains are not suitable for this by design or simply lack the required capacity.

Traditional online databases usually use a client-server network architecture. This means that users with access rights can change entries stored in the database, but the overall control remains with administrators. When it comes to a blockchain database, each user is in charge of maintaining, calculating and updating every new entry. Every single node must work together to make sure they are all coming to the same conclusions.

Blockchain technology architecture also means that each node must work independently and compare the results of its work with the rest of the network, so reaching a consensus can be very time-consuming. Because of this, blockchain networks historically have been considered slow when compared with traditional digital transaction technology. Advancements have increased blockchain-related transaction speeds in some cases, as seen in some crypto assets, projects and solutions.

That said, there are experiments in producing databases with blockchain technology. These platforms aim to take an enterprise-class distributed database and build on top of it while adding the three key attributes of blockchain: decentralization, immutability and the ability to register and transfer assets.

Where can blockchain technology be used?

The last portion of this article will discuss some of blockchain’s many applications. Blockchain technology is particularly ideal for what are known as “smart contracts.” So, what exactly are smart contracts?

Smart contracts define the rules and penalties around a specific agreement, similar to the function of traditional contracts. The big difference, however, is that smart contracts automatically enforce those obligations. Thanks to their coding, smart contracts discharge on the fulfillment of specific criteria.

Decentralized finance

Decentralized finance, or DeFi, is the utilization of blockchain technology that allows participants access to features similar to those common in the mainstream financial world, except in a decentralized fashion. Using different DeFi solutions, participants can loan and borrow funds — as well as access other opportunities — governed on the blockchain away from the control of a centralized authority.

Nonfungible tokens

Nonfungible tokens, or NFTs, serve as an application of blockchain technology with vast potential in a number of different use cases. Such tokens are verifiably unique and are not exchangeable one-for-one with others for the same value. One potential use case for NFTs is the authentication of artwork, with art pieces tied to NFTs, which can verify their authenticity and ownership.

Supply chains

The supply chain is another use case for blockchain. Applying blockchain technology to a supply chain can provide the ability to track ingredients, foods, materials and more back to the source to prove their origins, as well as to provide other pertinent information about any given supply chain. 

Warranty claims

Settling warranty claims can be expensive, time-consuming and often difficult for those making the claim. It is possible to implement smart contracts using blockchain technology, which will inevitably make the process notably easier.

In the traditional system, when a claim is made, people carry out all checks, which can be time-consuming and leave room for human error. This could potentially become unnecessary, as criteria checks can be done automatically using the blockchain. Once all obligations are fulfilled, the resulting payout is automatic. This can all be done using minimal human involvement.

Insurance claims

With smart contracts, a certain set of criteria for specific insurance-related situations could be established. In theory, with the implementation of blockchain technology, you could just submit your insurance claim online and receive an instant automatic payout — pending, of course, that your claim meets all the required criteria. 

Identity verification

Too much time and effort are currently wasted using existing identity verification methods, which also pose security risks. With blockchain and its decentralization, the verification of identity online could be much quicker and potentially safer. 

Keeping online identity data in a central location could become a practice of the past with the use of blockchain, meaning computer hackers would no longer have centralized points of vulnerability to attack. Blockchain-backed data storage is also tamper-proof and incorruptible. Blockchain technology could also apply to medical information, improving related processes and security. 

The Internet of Things

Linked together via the internet for interaction purposes, the Internet of Things, or IoT, is an ecosystem of software-friendly items, such as vehicles and devices, which include certain technological specifications that make such interaction possible. Blockchain technology and its smart contracts may prove helpful.

Blockchain technology could play a role in the future of IoT, partly by providing potential methods for guarding against hackers. Because it is built for decentralized control, a security scheme based on it should be scalable enough to cover the expansion of IoT. Moreover, blockchain’s strong protection against data tampering could help prevent the relaying of misleading information by a rogue device, which could essentially disrupt a home, factory or transportation system.

Archiving and file storage

Google Drive, Dropbox and others have thoroughly developed the electronic archiving of documents with the use of centralized methods. Centralized sites are tempting for hackers. Blockchain and its smart contracts offer ways of reducing this threat substantially.

A number of decentralized cloud storage solutions have surfaced over the years. By harnessing blockchain technology, these solutions allow participants to buy and sell storage access in a decentralized fashion. 

Fighting crime

Lawbreakers must hide and camouflage the money gained from their exploits. This can be done through fake bank accounts, gambling and offshore companies, among other strategies. Many concerns exist regarding the transparency of cryptocurrency transactions, although all the necessary regulatory elements — such as identifying parties and information, records of transactions, and even enforcement — can exist in the cryptocurrency system thanks to blockchain technology.

As the technology gains more mainstream attention, blockchain and its smart contracts have the potential to help in the fight against money laundering tactics.

Social media

Social media organizations request from their users the right to use their profile information and all uploaded content. Social media options are typically centralized, more subject to breaches, and governed by a single entity. Blockchain technology could potentially decentralize social media, possibly adding protection against hacks, making content more censorship-resistant, and giving users more control over their data. 

Voting

Voting, with regard to things such as elections and more, could be greatly improved with smart contracts and blockchain. Various related applications have come into existence over time. Among a number of benefits, incorporating blockchain technology into voting could potentially make future history more tamper-resistant and transparent.

Limitations and vulnerabilities

Aside from Bitcoin’s blockchain, a vast number of other blockchains exist on which projects can build solutions. Additionally, some projects decide to develop their own mainnet blockchains. Any blockchain network largely depends on the number of active users within it. In order to operate at its full potential, a network has to be robust, with a widely distributed grid of nodes.

Moreover, blockchain technology still struggles in terms of transaction speeds when compared with major card issuers such as Visa or Mastercard. 

Finally, there is always a theoretical possibility of the large-scale capture of any given blockchain network. If a single organization could somehow manage to gain control of the majority of the network’s nodes, it would no longer be decentralized in the full sense of the word.

Enterprise blockchain 

Enterprise blockchain refers to mainstream giant companies incorporating blockchain technology into their infrastructure. Numerous mainstream companies have looked into various applications of blockchain technology. Other mainstream companies have also come up with frameworks and tools as pick-and-shovel-type offerings to help entities incorporate the technology into their endeavors.

These blockchains do not typically have native coins in the same way that is seen in the crypto space, and network participants do not compete for rewards, they simply conduct confirmations.