What is a Smart Contract?
To understand a smart contract, we must first remember what a contract means. A contract is nothing more than an agreement between two or more parties, an environment where what can be done is defined, how it can be done, what happens if something is not done. In other words, some rules of the game that allow all the parties that accept it to understand what the interaction they are going to carry out will consist of. To day contracts have been oral documents or expensive written documents. These documents are subject to the laws and territorial jurisdictions, and sometimes require notaries. That is, more costs, time and third parties involved in the process. Because of this, they are not accessible to everyone. And this is not the worst: the contents of contracts may be subject to interpretation. Hold on!
On the other hand, a smart contract is capable of executing and enforcing itself, autonomously and automatically, without intermediaries or mediators. They avoid the burden of interpretation by not being verbal or written in the languages we speak. Smart contracts are “scripts” (computer code) written with programming languages. This means that the terms of the contract are pure statements and commands in the code that forms it. On the other hand, a smart contract can be created and called by natural and/or legal persons. But also by machines or other programs that work autonomously. A smart contract is valid without depending on authorities. This is due to its nature: it is a code that is visible to all and cannot be changed as it exists on blockchain technology. This gives it a decentralized, immutable and transparent character.

Smart contracts and their enormous potential.
With the above, surely you have been able to see the enormous potential that these smart contracts contain. It is important to note that, as it is distributed over thousands of computers, it prevents a large company from keeping them safe, which eliminates bureaucracy, censorship and the large implicit costs/times of this process which, by the way, until now is the safekeeping . If we combine the principles of a smart contract with the creativity of many developers on the planet, the result is never-before-seen possibilities, accessible to everyone and at costs that are close to free. Ecosystems without authoritarian figures that submit their members to their will. We talk about a fairer world. Imagine a self-driving, group-bought Tesla car capable of self-management and self-rental. All this without an Uber-type company behind taking 10%. From that we can say: welcome to the world of smart contracts.
The first smart contracts.
The first time that smart contracts became publicly known was through Nick Szabo, a lawyer and cryptographer Nick Szabo publicly mentioned the term in a document in 1995. Two years later, in 1997, he developed a much more detailed document. explaining Smart Contracts. Unfortunately, despite defining the theory, it was impossible to make it a reality with the existing technological infrastructure. In order for smart contracts to be executed, there must be programmable transactions and a financial system that recognizes them, digitally native. Precisely what Szabo defined as non-existent in 1995, in 2009 (almost 15 years later) would become a reality with the appearance of Bitcoin and its technology, the blockchain.
Bitcoin and smart contracts.
Bitcoin has some smart contracts already created that are executed by default and transparently to the user. When we talk about distribution contracts, we are referring to one of the use cases of Bitcoin to form agreements between people through the blockchain. And it is that Bitcoin, among all its advantages, allows you to add logic to money, something unique to this type of money: it is programmable money. This logic applied to money allows us to solve common problems that we can find today, but increasing the level of trust throughout the entire automated process in which the interaction takes place.
Examples of smart contracts in Bitcoin.
By way of example, new products or applications could be developed, such as:
Distributed markets that would allow the implementation of P2P contracts and trading in the markets with Bitcoin, presenting itself as a complete competitor to the current financial system.
Properties such as cars, telephones, houses or non-physical elements controlled through the chain of blocks make up the so-called smart property. Through the use of contracts and with smart properties, the level of trust is allowed to be much higher, reducing fraud, mediation fees for third parties and allows operations to be taken to a new level. Inheritance automation establishing the allocation of assets after death. As soon as the death arrived, the contract would enter into force and would be executed, in this case distributing the funds to the address established in the contract.
Insurance: accident reports, company payments for repairs, reduction of fraud in accidents…
And it is that smart contracts use Bitcoin technology to exist, something that is great for Bitcoin, since it is making it receive much more attention, bringing hundreds of thousands of new users to its ecosystem. In fact, it is not difficult to find statements of the type: “Smart contracts are the killer APP of Bitcoin”.
This logic that can be applied to Bitcoin transactions is done through the use of its own language, allowing the blockchain itself to determine what to do based on the programmed indications. This means that we have a transaction with some instructions in a distributed and immutable way, giving complete security and without interpretations.
Something important to keep in mind.
Today everything is controlled by computer systems. Everything interacts with them. In application development it is normal for programmers to create a series of “doors” to their application (called APIs). These doors allow other programmers to enter your application to create or obtain information. Almost all websites or programs have theirs. That is, a protocol is defined, a contract, a known way in which the application is called with a data structure. It is through this gate that we are going to get a response, but with a predictable data structure. In this case, so that the communication and, with it, the programs do not fail. But this contract is not guaranteed. The application server is controlled by someone who has the ability to make the program work differently tomorrow. It is centralized and can mutate at the decision of that third party. It’s not “smart”. People need predictable, transparent and incorruptible environments. Smart contracts are similar pieces of code, that is, they have ways of calling them and getting responses, they have a contract, but they are also immutable since they are distributed in thousands of nodes that cannot alter their content. In this way you obtain a program that will always act in the same way without requiring the good will of that third party. Something that for almost any use case is necessary. Smart Contracts are programs in the cloud that always act the same, and allow information to be stored that cannot be treacherously modified. They are the most secure programs ever created by mankind and they only fail when they are badly programmed.
Poorly programmed Smart Contracts.
Smart Contracts are capable of managing digital assets, subject to a certain economic value, so Smart Contracts can actually manage money. This requires that special emphasis be placed on its correct programming, since the Smart Contract could have security flaws or failures that generate execution errors or unexpected behavior. When this happens, the money can be completely lost. It has happened not infrequently and without sufficient Know How it will continue to happen to many initiatives.
Unfortunately this happens frequently, so it is really important to pay special attention when developing and testing these pieces of software.
How is a smart contract made in Bitcoin?.
For all this to be possible, there must be a completely secure process that guarantees that at least two parties can execute the contract without having to trust each other, or even know each other. The contracts use the decentralized system of Bitcoin to enforce financial agreements without reliance on external agents, such as judicial systems, decreasing the risk of dealing with unknown entities in financial transactions.
Generation process of a smart contract.
There are several steps to creating secure smart contracts. Let’s exemplify the case of making secure deposits on any web page that accepts bitcoins. Nobody likes to lose their money, right? Taken together, all these characteristics not only allow the construction of new and interesting financial tools on the Bitcoin blockchain, but also, since each smart contract is made up of people or machines, the possibilities of innovation for the field of Internet of Things, Insurtech, Logistics , Administration are so extensive that it is likely that the first killer apps or revolutionary applications in these areas will begin to appear very soon.
Steps for the generation of a smart contract.
-The user and the web page send each other a newly generated public key.
-Then the user creates the first transaction without transmitting it, putting for example 5 BTC in an output that requires both the user and the website to sign it.
-The user sends the hash of the first transaction to the web page.
-The portal creates a second transaction corresponding to the contract. In this second transaction, the first is spent and returned to the user through the address provided in the first step. But since the first transaction required two signatures (user and web page) this operation would not be complete yet. This is where a new parameter becomes important: nLockTime.
-This can be added to a bitcoin transaction by setting a future date of say 6 months. Prior to this date, those funds could not be incorporated into any transaction.
-The Sequence Number of the input is also set to 0.
-Eventually, the fully unsigned transaction would be returned to the user.
This would verify that everything is correct and that the coins would return to his possession. Of course, after the 6 months that were stipulated with nLockTime. By having the Sequence Number at 0, this contract could be modified in the future if both parties see fit. But of course… If the administrators of the website disappear, how could the user recover the funds? It must be taken into account that the input script (instructions recorded in each transaction) has not yet finished. The space reserved for the user’s signature is still made up of a set of zeros after the portal will create the second transaction. Now all that is missing is the user’s signature in said contract. From here, after the 6 months that were delimited, both the first and the second transaction would be transmitted and the 5 BTC of the first transaction would be returned to the user in question.
Taken together, all these characteristics not only allow the construction of new and interesting financial tools on the Bitcoin blockchain, but also, since each smart contract is made up of people or machines, the possibilities of innovation for the field of Internet of Things, Insurtech, Logistics, Administration are so extensive that it is likely that the first killer apps or revolutionary applications in these areas will begin to appear very soon.
Responses