Blockchain and Smart Contracts: functioning and key points
A decentralized world
Without any doubt, and largely thanks to the world of cryptocurrencies (and the money it moves), one of the words that we have heard the most in 2022 in technological matters is Blockchain. While this has been somewhat overshadowed by the great advances in Artificial Intelligence, with Stable Diffusion and ChatGPT at the forefront, it is still one of the most promising cutting-edge development fields. But what exactly is a Blockchain? What’s so special about it? Let’s have a look at it.
How Blockchains work
A Blockchain is a distributed ledger organized into blocks of cryptographically related and secure transactions. Although the definition may seem simple, its structure and operation are quite the opposite. To solve questions such as what a block is, how a transaction is carried out or what role cryptography plays in all this, we will have to delve a little deeper into this exciting technology.
To begin with, we will try to visualize the concept to try to facilitate the understanding of it. For this we will start from its name, because a Blockchain can literally be seen as a chain of blocks. These blocks function as accounting books, where the different transactions carried out are recorded.
![Block](https://gonware.com/wp-content/uploads/2023/01/Block.png)
![Basic Blockchain](https://gonware.com/wp-content/uploads/2023/01/Basic-Blockchain.png)
Each member of the network has a copy of this accounting chain and can participate in its development. Depending on the type of Blockchain we are talking about, may or may not enter it. Therefore, we can distinguish between:
- Private blockchains: although the system is decentralized, there are coordinating users and certain authority figures. Access is restricted.
- Public blockchains: there are no authority figures and any interested user can enter them.
- Hybrid blockchains: sometimes intermediate solutions are reached, allowing anyone who wants to enter to do so, but maintaining some control over the system.
The question now is: What is transferred? Well, each Blockchain has its own token, which is nothing more than its currency. However, although its nature is very comparable to that of a currency, a token can represent anything, such as the unequivocal ownership of an asset (the famous NFTs), a certain amount of energy…
Delving into cryptography
Extremely linked to the Blockchain world, there is the world of cryptography. Backed by the latter, this cutting-edge system allows you to guarantee the integrity of the information it houses. Before moving forward, we must first know a crucial concept that we will be using from now on, the hash.
A hash is a sequence of characters obtained as a result of a mathematical hash function. These functions are characterized by algorithms capable of transforming the input data into an exclusive output result. Therefore, two different entries will not result in the same hash. But even more remarkable is the fact that, although obtaining the hash of certain data is a fast process, reversing it and obtaining the input data from the hash is an extremely expensive process in terms of time. This is where the fundamental value of the Blockchain lies: its cryptographic security.
![Hash](https://gonware.com/wp-content/uploads/2023/01/Hash.png)
![Reverse hash](https://gonware.com/wp-content/uploads/2023/01/Reverse-hash.png)
Block parts & consensus
The Blockchain world is very broad, and the application of this technology is compatible with strategies and solutions of all kinds. Therefore, for each case, the chain block may differ in different aspects. Even so, we can generalize and identify the following parts:
- Data: this is the most customizable part. This is where transactions and information about them are recorded. To ensure the integrity of these transactions, each user who transfers tokens to another user on the network signs (with a hash) on the block of that exchange.
For this process, an asymmetric encryption algorithm is used. These algorithms provide each user with two keys, one public (accessible to any member of the network) and one private (which they must keep secret).
The signing process is simple, the user in question takes the content of the transaction and his private key and, making use of a hash function, obtains his signature relative to the transaction.
If any other user wanted to verify that this transaction is legitimate, they could do so by using the content of the transaction, the signature (supposedly of the user who has transferred tokens) and the public key of the same.
![Signature](https://gonware.com/wp-content/uploads/2023/01/Signature.png)
![Verify signature](https://gonware.com/wp-content/uploads/2023/01/Verify-signature.png)
![Refined block](https://gonware.com/wp-content/uploads/2023/01/Refined-block.png)
![Refined Blockchain](https://gonware.com/wp-content/uploads/2023/01/Refined-Blockchain.png)
- Current block hash: each block calculates its hash using its transactional data and the hash of the previous block as input.
- Hash of the previous block: to relate the blocks with each other and establish an order, each block includes the hash of the immediately preceding block. There is a block that does not have this field and whose content is arbitrarily completed. We are talking about the first block of the chain, the only one that does not have a predecessor, which is called the Genesis block. If you tried to modify, even slightly, the content of any of the existing blocks in the chain, its hash would change, the block would be unlinked and consequently the chain would become broken.
As we mentioned earlier, calculating a hash is a quick process. So, what prevents the modification of a block and the subsequent recalculation of all hashes? This is where the figure of the consensus protocol appears. To solve this problem, there are different proposals on the table, among which the following stand out:
- Proof-of-stake: randomly selects a network node to validate the issued block. This method is risky, since coordinating multiple nodes in the network could put the system at risk.
- Proof-of-work: generates a cryptographic challenge to be solved with the block to validate it. The nodes that want to compete are called miners, and only one, the first to solve it, wins. This method is more robust but much more computationally expensive, which leads to a higher energy consumption.
In both cases, the node responsible for verifying the block is rewarded with a certain amount of tokens, which are either created or are the result of charging transfer fees. Finally, the brand new block is incorporated into each user’s chain and the process begins again. Another design issue to solve is to determine the size of the block and the time it will take to generate a new one. Example: Bitcoin, the benchmark of the sector, generates a new block every 10 minutes approximately.
Strengths and applications
Surely, the main question that comes to mind being aware of the great stir and expectation that surrounds this issue and the great effort behind it is: what benefits does it bring us to work with a Blockchain instead of with a traditional system? Here is a list of its main strengths:
- Security: The cryptographic methods detailed above, together with the appropriate consensus strategies, result in a highly reliable, and therefore extremely difficult to counterfeit solution.
- Anonymity: although the transactions carried out are available to everyone, the identity of the owners involved in it remains secret.
- Traceability: the possibility of auditing the origin of an asset and visualize previous transactions of the same is very interesting for some industries (such as logistics) and certain use cases.
- Efficiency: by being able to automate multiple and diverse manual and expensive processes frequent on traditional systems, waiting times are reduced and the network is given great agility.
If we had to identify a sector as a pioneer, it would be none other than banking. Of course, this system of transactions was especially suitable to enrich, facilitate, optimize and cheapen the immeasurable monetary operations that are carried out daily. Even so, other very diverse sectors show a growing interest in integrating this technology into their procedures, from the renewable energy sector to online betting and gambling.
Smart Contracts
Although the Blockchain is already very useful and valid to evolve businesses and entities of all kinds, it was not until the appearance of Smart Contracts that the range of possibilities to be implemented expanded enormously. What is a Smart Contract and what role does it assume within this framework?
Smart Contracts are contracts formulated on a Blockchain with the ability to execute automatically as its clauses are met. Programmatically elaborated, they would execute the relevant token transactions within their Blockchain as the events that concern them take place.
As is evident, these types of solutions bring with them certain advantages of great value:
- No notary: by dispensing with a centralized figure of trust and being able to draw up the contract directly between the interested parties, the notary costs linked to it disappear as they are totally unnecessary.
- No expert verification: the possibility of automating sources of information to check the effectiveness of the agreed clauses implies that we will not need expert opinions to verify them. This is where Blockchain and the Internet of Things could be combined to further refine the implemented system.
Different social and legal applications are postulated as candidates, but among all the sectors where these futuristic contracts could be applied, we can highlight one that shows special interest in integrating them into their day to day as soon as possible. This is none other than the insurance sector.
With thousands, if not millions, of contracts established with their clients and with a number, although smaller not insignificant, of parties from the latter, the ability to fully delegate the hiring, valuations and payment of indemnities in a reliable system based on Blockchain, would be a turning point and a considerable increase in the profits of these companies. On the part of the client, just imagining that, after having an accident, it would be a matter of minutes to receive the compensation money without having to process absolutely nothing is interesting, right? This example also highlights the value of the aforementioned symbiosis with the IoT world. Today’s vehicles increasingly have more sensors, and every day there are more that incorporate Internet connectivity, then, although it may seem a utopia, we are not so far from seeing it become a reality.
My forecasts
From my point of view, a slow transition from the Internet of Information to the Internet of Value has begun. Although we continue to live with the first as we have been doing so far, the focus of the most important developments will surely shift to the second over time. A true revolution that will be a turning point for many industries. What will these notorious technologies achieve?