- March 8, 2022
- Blog
Introduction to Blockchain
Hello! My name is Niels Wouters. I’m a consultant .NET developer at Digital Unity interested in Blockchain. Today, I want to introduce you to the Blockchain. This introduction can help you decide if Blockchain is the way forward for your business.
Building a solution that multiple companies/partners will use can be challenging because you need to trust data from external sources. Usually, all this data comes together in a central database, stored in one location, and is the source of truth. Therefore, the company that maintains this database must be trusted as the central authority of the data.
Blockchain lets you implement business processes where you need to trust data and partners without using a central database so no manipulation can happen.
What is Blockchain?
Blockchain is a record-keeping and contract-enforcement technology that uses cryptography to make it extremely difficult to change the previous history. It allows partners to track changes on the shared ledger and act when actions should trigger a business processor to validate the changes from other partners.
Centralized database
The advantage of a centralized database is that it’s easy to manage access permissions and data consistency. Everyone uses the same database, and there’s a trusted authority managing access to data. However, because there is only one database, all partners use the same data set. Therefore, everyone needs to trust that the database is correct, and they need to trust the database owner not to manipulate historical data.
But what if your solution doesn’t allow for a trusted central authority, and nobody wants to have all the responsibility for hosting the centralized database because of sensitive data? Or maybe it’s just not possible because of integration requirements by all the partners.
Distributed database
A distributed database uses multiple copies of a database, and all changes are synchronized. In most cases, it’s easier to control access and integrate your systems and processes in your copy of a database. However, synchronization of changes to each database is required. In addition, handling failures and conflicts can add complexity and data integrity issues.
Distributed ledger
Now we get to blockchain technology. We refer to Blockchain as a distributed ledger. A ledger is a history of transactions, and each transaction affects the final state. When you distribute Blockchain networks between partners, they are called consortium networks.
Blockchain uses a consensus algorithm to ensure data is consistent across all nodes. It also uses cryptography to validate the partners and the data they send or receive. These algorithms combined prevent any malicious individual from modifying the ledger history.
How Blockchain works
Now that you know the basics of Blockchain let’s see how it works behind the scenes. This information will explain all the components in a blockchain network and help you decide whether Blockchain will work for your scenario.
Blockchain nodes
A blockchain network consists of nodes that have a copy of the ledger. All partners don’t need to have a node. Partners can share nodes, and they can even have multiple nodes. So there doesn’t need to be a one-to-one relationship of nodes to partners, but more nodes equal a more secure blockchain network. All transactions sent to the blockchain network will be distributed and validated among all the nodes.
Blockchain Data
Data in a blockchain represents a state. That’s why digital tokens like cryptocurrency are a good fit for Blockchain. If we think about the ownership of physical currency, a coin can only be in one person’s pocket at a time. If the coin is in your pocket, the state of ownership is yours. If you give that coin to your friend, the state changes to your friend owning it.
Blockchain uses transactions to change the state of the data from one value to another. For example, if we send cryptocurrency tokens to another person, a transaction to change ownership gets sent to the blockchain network.
Consensus
Blockchain uses a consensus algorithm to validate and agree on the data and transactions across all blockchain nodes. Consensus allows all decentralized nodes to come to the same state. When transferring value or responsibility, the order of events is crucial for the algorithm. For example, if you give a coin to your friend, you can’t also send that coin to a colleague. This issue is known as the double-spend problem, which consensus solves. Consensus ensures the correct order of transactions and the integrity of the Blockchain. As part of the consensus, a group of transactions is validated as a block. The network must agree if the data block should be included in the Blockchain. There are several blockchain consensus algorithms, including proof of work, proof of stake, and proof of authority. Each algorithm solves consistency differently but achieves the same goal.
Block of transactions
A block is a cluster of data within the Blockchain that stores transaction information. The number of transactions in a block is usually time-based. For example, the bitcoin network processes a block every 10 minutes or a maximum block size of 1MB.
The network validates blocks and adds them to the Blockchain in different nodes. Because of this, all the nodes have the same blocks, and the ledger is consistent across the network.
Immutable ledger
Every node has control of its ledger. Can’t you change the transactions manually and manipulate the data? No, Blockchain uses a cryptographic hash to create links between blocks. The order of transactions can be agreed upon through the consensus algorithm by linking blocks.
A cryptographic hash is an algorithm that maps data to a bit representation of a fixed size. You can think of it as a digital fingerprint. For example, Bitcoin uses the SHA-256 hash algorithm. If you used an SHA-256 hash function on a 100-page document, the function output is a 256-bit hash value. If you change just one character in the document and regenerate the hash, the result is a different 256-bit hash value. Now, imagine using a block as the input to the hash function. The output is a unique hash value for the data in the block.
Blockchain uses hashes to detect if any changes have been made to the blocks. By including the previous block’s hash value when generating the next block’s hash, blocks are chained together through hashes. If any block is modified in the chain, the hash of later blocks is different. As a result, when validating the ledger, you will see errors in the data.
Trusted logic
Blockchain allows us to store data that is consistent and can be trusted. So how do we add logic that executes the same at each node?
A decentralized application (DApp) is a distributed computing system application. For example, we’ll focus on using the Ethereum blockchain protocol. Ethereum DApps are called smart contracts. A smart contract contains logic that is executed as part of a transaction. On Ethereum, you program the logic using a programming language called Solidity.
Smart contracts are deployed to the Blockchain and are referenced by an address. To use a smart contract, you create an instance. A smart contract instance contains state data and program logic. Just like data in the Blockchain, a smart contract is immutable. You cannot change the program’s logic after you’ve deployed it. Therefore, you can trust that smart contract logic always executes the same on all nodes. Any code changes require a new smart contract deployed at a new address.
Conclusion
Blockchain technology works best for specific scenarios. Therefore, it would be best not to use it as a general-purpose solution. In many cases, a centralized database is a better option. When considering using Blockchain, ask yourself these questions about your scenario.
- Do you need to support multiple partners or companies?
- Do you want to avoid a central authority?
- Do the participants share data or use a workflow that involves several or all the participants?
- Is your transaction throughput low?
- Is there defined business logic when interacting with other business partners?
- Is your business logic simple?
- Is your business logic static and doesn’t change?
- Are trust and integrity required between participants?
- Does the order of transactions matter?
- Do you need transaction privacy?
This concludes my introduction to Blockchain, and hopefully, you now have a better understanding of blockchains. Maybe you will even implement Blockchain in a future project!
Blockchain technology is still being developed and improved with new blockchains and solutions every day! Don’t hesitate to contact Digital Unity for more information!