It is a term that appears countless times once someone knows the world of Bitcoin, the cryptocurrencies and the blockchain, so we have decided to study it and explain it to you in a simple way.
What exactly are smart contracts?
To understand them, let us take a step back for a while:
Evolution of traditional contracts
When we speak of contracts, the typical paper document with written conditions comes to mind, in which if the parties involved agree with them, they write their signature on it, committing themselves to comply with these conditions.
We have all signed some of those.
Today, although this method is still the most widely used in the world, it has also evolved slightly, finding us with:
Digital signature contracts
Contracts requiring voice confirmation
When you accept those terms, you automatically “sign” that contract with that website.
This happens in any portal where you have to register, such as social networks like Facebook or Twitter, online stores such as Amazon, or service platforms such as Airbnb.
Contracts that require voice confirmation are those in which your signature is your own voice accepting the terms of the contract.
This is common in telecommunication companies such as Orange or Vodafone, among others. These companies call to offer a service with some conditions.
If the user agrees with these conditions, the company takes note of the legal data of that person (name, address, DNI…) and makes him answer “I accept the conditions”, recording his answer as “signature” of the user.
The above-mentioned form the traditional contract format, however, they are evolving towards what today are already called smart contracts.
Next, we are going to explain in detail what they are, how they are executed and their applications:
What is a Smart Contract?
A smart contract is a computer program that executes agreements established between two or more parties causing certain actions to happen as a result of a series of specific conditions being met.
That is, when a pre-programmed condition is met, the smart contract automatically executes the corresponding clause.
They are contracts that execute and enforce themselves automatically and autonomously.
Smart contracts have been in development since 1993 when the famous cryptographer Nick Szabo first introduced the term.
Nick proposed this system of contracts at the time, but the technological infrastructure of the time made it unfeasible.
There was a need for a payment system that could put them into practice and that situation did not appear on the scene until the creation of Bitcoin in 2009.
However, Bitcoin was not intended to be anything more than a financial tool: a cryptocurrency -the coin- and a platform for exchanging value -its blockchain-.
On the other hand, the technology with which it worked – the blockchain- did make these smart contracts possible and it was at the beginning of 2014, with the creation of Ethereum, when they finally became a reality.
These smart contracts “live” in an atmosphere not controlled by any of the parties involved in the contract, in a decentralized system.
This means that:
The conditions are programmed,
Signed by both parties involved
And it is ‘placed’ in a blockchain so that it cannot be modified.
These evolved contracts have as the main purposes:
To implement a state of security greater than that of the traditional contract
Reduce the time associated with this type of interactions
In other words, they seek to improve current contracts by being safer, cheaper, saving us time and avoiding fraud.
Traditional Contracts vs Smart Contracts
When we talked about paper contracts, we know that they are written in a natural language: you can write in any language but in a legal context understandable between two people.
Once the terms are accepted and signed, according to the applicable laws, the legal responsibility of both parties has costs that usually come from a notary, giving validity to that contract.
We also know that its mode of performance depends on the point of view of each party involved: in a contract, clauses tend to benefit one party over the other.
On the other hand, smart contracts differ on these three points:
Language is not natural, it is a virtual language, a computer programming language. Just as every computer program or mobile application is programmed to perform a certain number of tasks, smart contracts also perform tasks under previously introduced instructions.
This means that in fulfillment mode there are no different points of view, but a single reading: If the set condition is met, the contract automatically executes the consequence to that action.
The legal liability of the smart contract continues to develop. What is clear is that it does not require an intermediary (such as a notary) since the contract itself is the trusted intermediary, thus reducing the costs and time of interactions.
How do Smart Contracts work?
Imagine a food vending machine like you would find at any airport or train station.
That machine is programmed so that when you enter a certain amount of money and press a combination of numbers, the selected product automatically leaves the machine to be yours.
In addition, another order that has scheduled is that, if you have introduced more money than the product cost, the machine will return the change, or if there is no selected product mark on the screen ‘Out of stock‘.
This programming of the machine is what the smart contract would be, and the parties involved are you and the machine.
The rules of the smart contract are the rules that we have mentioned before and that are executed by themselves if the corresponding actions are fulfilled.
This works in computer language as a sentence called ‘if-then’, which means:
“if the agreement is fulfilled… then the condition is met”.
In the example above, these agreements with the ‘if-then’ sentence would be something like this:
If the user enters enough money and presses the combination ‘032’, then the water bottle will come out. If it is satisfied that the user has inserted more money than necessary, then the difference is returned. If the user introduces the money and presses ‘032’ but there is no item, then put ‘Product Out of stock’ message.
This is how a smart contract would work.
You will think: “But these machines have been around for so many years! What is new here?”
However, in this example and with a somewhat advanced vision, the smart contract that this type of machine would have programmed would be that “if the product ‘032’ is finished… then” – autonomously and automatically – the machine will send a signal to the water bottle supplier to replace them”.
This eliminates an intermediary who has to be watching the machine, calling the suppliers and replenishing it himself, thus also eliminating the costs and the time spent in this process and simplifying the task much more.
On the other hand, this is a mini-contract programmed into a simple vending machine. Imagine how complicated the issue becomes when we talk about employment contracts, property rental contracts or sales contracts.
Another example could be renting a property.
Nowadays there are already electronic locks that are opened with a card like those found in many hotels and companies around the world. As long as the card associated with the door is active, you can enter and exit whenever you want.
In the case of the hotel, imagine what it would be like with a smart contract: if you have paid until the 30th of the current month and the hotel rules are that you have to leave before 11:00 in the morning, the card will work until the 30th at 11:00 in the morning.
At 11:01h you will no longer be able to open the room. Those would be the rules of the contract that executes itself once it passes that hour.
This would make an Airbnb possible but without its mediation or their commissions. And the same could happen with platforms such as Uber or Blablacar: act directly between interested people (peer-to-peer relationships), through a smart contract, saving the commissions of such platforms and management time.
There could also be the case of the purchase of a property.
For example, if Carlos wants to buy Pablo’s house in monthly payments, and they want to do it through a smart Ethereum contract, they must agree on rules to follow such as:
The monthly amount
The day of the month in which the payment is due
The total amount to pay for the property
Also important data such as that if Carlos does not pay the monthly money established on the established date to Pablo, the lock of the house will be blocked until the payment is not made, or that Pablo will transfer the title of the property to Carlos without being able to back out.
Once the rules of the contract have been established and implemented, the contract will act autonomously and automatically without the need to have Carlos and Pablo interacting with each other and seeking mediation in case of disagreement.
To summarize, a smart contract works in a way that the parties configure the terms of the contract, it is stored in a blockchain and when the terms described are given, the system executes the contract and the consequences described in it are produced.
What is the Oracle and how does it relate to a smart contract?
Let us continue with the examples as a didactic method.
Let us say Carlos and Pablo are football fans.
Carlos is Real Madrid supporter and Pablo is FC Barcelona supporter. Carlos wants to bet 5 Ether (Ethereum’s token) that Real Madrid wins the next ‘Clasico’ and Pablo wants to bet the same Ether that FC Barcelona will win it.
They carry out the bet through a smart contract, specifying the rules of the contract and depositing the funds in an account.
Once it is known who wins, the contract will distribute either way the total of Ether bet automatically.
In this case, an entity external to the contract has to tell it who has won, and that entity is the Oracle.
This tool allows you to update the status of smart contracts with external information, such as which team won the match.
It is true that this entity is external to the blockchain, it is a third party, an intermediary that must be trusted, and therefore this has an impact on the centralization aspect, something totally opposite to the blockchain technology purpose.
In order to solve this introduction of an intermediary in the chain and decentralize the obtaining of this result, there are projects that act as information carriers between the external services (APIs) and Ethereum blockchain. An example of this is Oraclize.
This project combines all the information portals that are indicated in the contract and relevant to it, and it is Oraclize that, depending on the results obtained, will make its final decision.
Multisignature function on smart contracts
The multi-signature function in smart contracts is a function through which two or more people must agree to enforce the terms of a contract.
Let us imagine that Ana and Luis are two friends who want to make a trip together to travel the world for a year. It is an expensive trip so they have to save a lot of money.
They decide to make a smart contract in which everyone has to put a set monthly amount of 500 euros until they reach 30,000 euros. The smart contract will block those funds until the conditions of the contract are met.
Once the amount of €30,000 is reached, one of the two could take out all the money on their own and that would be a problem, but something like that will not ever happen if there is the multi-signature function.
This feature allows all the members -or a percentage of them- to approve the action.
In this particular case, Ana could not get the money out without Luis agreeing, and vice versa. Through the multi-signature function, it is both of them who have to agree, making it so that neither of them can take over the whole of the money.
Smart contracts’ Double Deposits
This is another feature of smart contracts that makes them work properly, eliminating the middleman from the process.
It allows two or more parties who do not know each other and lack trust in each other, to perform a secure transaction for both through a smart contract.
This contract obligates them to deposit in one direction of the blockchain some funds for the fulfillment of the contract.
The contract has a fixed duration, and if they do not reach an agreement, the smart contract will directly send the funds that both parties had to pay to another direction of the blockchain from which nobody will ever be able to take them.
What this condition does is to force everyone to fulfill their part of the contract. Otherwise, the funds would disappear.
Let us move from theory to practice with an example:
Let us say Raymond wants to buy a plate of Thai food from Khalan that costs 10€.
In the traditional method, if you do not pay before, there is no food, but between individuals it could be the case that Raymond pays the 10€ and Khalan does not send him the food, thus keeping the money.
Or that Khalan trusts Raymond, sends him the food before receiving the money and he does not pay him.
There would be a problem of trust on the other side.
Through a smart double deposit contract, Raymond would pay 10€ on the smart contract and another 10 as a security deposit.
Khalan would also pay 20€ but only as a security deposit.
The smart contract will be executed according to the rules that Raymond and Khalan have agreed, i.e. it will be executed if Raymond receives the plate of Thai food and Khalan receives the 10€.
If this happens -that both receive what they agreed- both parties will also receive their security deposit as compensation for having enforced the security of the contract.
In other words, they will receive the money back for doing things as agreed. If, on the other hand, one (or both) of the parties does not comply with the agreement, no one will get any money, they will lose it as a penalty for not having complied with the agreement.
In conclusion, this double deposit with the security deposit makes it impossible for one party to win without the other, i.e., there are no cheating and it makes people reach friendly settlements. Such methods have already been added in some decentralized markets. We can see them in portals such as Bithalo and Blackhalo.
Uses of Ethereum’s Smart Contracts
Based on the fact that the Ethereum platform, blockchain technology and smart contracts are novel tools, the uses of smart contracts today are not even close the same as they will be in the future.
Just like the Internet was never thought to send emails and yet, today, we continue to discover new uses of the “Network of Networks”, smart contracts can be applied to virtually everything.
Those that you will find next are only some of the possible uses that could be given to it:
Loans: if the person who contracts the loan does not make the payment in the stipulated time, the contract would be executed to remove the guarantees.
Transaction settlement: Contracts calculate settlement amounts and transfer funds automatically.
Coupon and bond payments: Contracts calculate and pay coupons automatically on a regular basis and return the capital at bond’s end period.
Micro-insurances: Calculates and transfers micro-payments based on usage data from an Internet-connected device (e.g. pay-per-use auto insurance).
Security deposit in the property register: the contract supervises the information external to the blockchain and once the property is transferred from a seller to a buyer, the contract automatically enters the funds to the seller.
Inheritance: once the contract can verify the person’s death, the property is automatically distributed and assigned among the heirs.
Automation of payments and donations: payments or donations can be agreed to persons or entities. The smart contract would do is to verify that the rules are met to make the donation automatically.
Electronic Medical Records: Contracts provide for transfers and access to medical records following approval of multiple signatures between patients and providers.
Access to population health data: health research organizations are granted access to certain personal health information. In return, through contracts, micropayments are automatically made to the patient for participation.
Personal health monitoring: actions related to the health of patients are monitored through IoT devices -Internet of Things- connected to the Internet. Contracts automatically generate rewards based on specific events.
Intellectual Property Services
Royalty distribution: smart contract calculates and distributes royalty payments to artists and other associated parties on agreed terms.
Autonomous recharging stations for electric vehicles: the contract processes a deposit, enables the recharging station and returns the remaining funds once completed.
Public sector services
Voting: validates voter criteria, registers the vote in the blockchain and initiates specific actions as a result of the majority vote. This is possible in a vote at both the survey level and the state level.
Betting: two or more parties can bet without their security being compromised and without the need for a third party through a smart contract that ensures concrete conditions.
Intelligent properties: a house, a car, a refrigerator, a washing machine…all properties that can be connected to the Internet are considered smart property. And they can all be managed with smart contracts so that they can be sold or rented automatically.
Benefits of Ethereum’s smart contracts
After we have defined what they are, let’s describe the benefits they have:
These contracts are always between one or more persons or legal entities but without any intermediary. There is no need for someone to validate the contract, such as a lawyer. Therefore they reduce, and may even eliminate any extra person who is not involved in the contract.
As they are contracts that do not depend on a third party, costs are reduced. Less human intervention results in reduced costs.
All smart contracts go straight to the blockchain. This makes it: 1) encrypted, so that only the people involved can read it, and 2) allows interaction between people who do not know each other without the risk of fraud.
Smart contracts use software code to automate tasks that would otherwise be performed manually. Therefore, they increase the speed of business processes and are less susceptible to manual errors.
As these smart contracts are based on Ethereum’s public blockchain they cannot be lost. Everything is recorded immutably. Nothing and no one can make it disappear and you always have access to them.
The decentralized execution process eliminates the risk of manipulation since the execution is automatically managed by the entire network, rather than by an individual party.
New business models
Smart contracts, through their low costs to ensure reliable transactions, enable new types of business such as automated access to vehicles and storage units.
This can open up new avenues of entrepreneurship if coupled with other emerging trends such as the Internet of Things (IoT).
How to create a Smart Contract?
Just as paper contracts are created by people who know the entire legal environment around them, in smart contracts it would be necessary to know the computer code used in Ethereum, called Solidity (open the link to learn more about it) or have someone who knows about it.
The best tutorials about creating smart contracts are currently these ones:
Today, not too many people have programming skills, which can be a problem for the development of these contracts.
Demand would be high and supply would not be able to cover it.
Fortunately, there are platforms that manage the creation of smart contracts. One of them is SmartContract, where these contracts can be created through Chainlink, its own blockchain, which acts as a link between Ethereum and external data sources.
Many experts suggest that smart contracts will enter our daily lives in a multitude of different ways.
The most obvious of course is the replacement of traditional contracts by lawyers, transforming them into standardized templates of smart contracts or merging them into a hybrid of paper and digital content where contracts are verified via blockchain and confirmed by hard copy.
However, as we have seen earlier in this article, its uses are going to expand to practically all areas of daily life.
In all areas where communication between two or more parties is necessary (whether these are live entities or machines), this type of contract allows this communication to be one hundred percent true, secure, fast and low-cost.
¡Compartiendo ayudamos a incrementar el valor del Ether!