The true leap that blockchain made towards the consolidation as a disruptive force capable of affecting the world on a multi-sectorial level, was brought by the smart contracts. But what is a smart contract? It came with the realization that a decentralized ledger able to serve as platform for trading electronic cash, could perfectly be used for other kinds of data, like complex programs or non-financial records. Smart contracts are pieces of code that can be stored in a blockchain, performing complex operations. It’s software with the ability of self-executing when one or many conditions are matched.
Smart contract is a term used to describe a computer program that is capable of facilitating, executing, and enforcing the negotiation or performance of an agreement, using blockchain technology. The entire process is automated and can act as a complement, or substitute, for legal contracts, where the terms of the contract are recorded in lines of code, as a set of instructions. For better understanding of the concept, see quoted the example that Vitalik Buterin, creator of Ethereum, used to describe the concept.
“Suppose you rent an apartment from me. You can do this through the blockchain by paying in crypto-currency. You get a receipt which is held in our virtual contract; I give you the digital entry key which comes to you by a specified date. If the key doesn’t come on time, the blockchain releases a refund. If I send the key before the rental date, the function holds it releasing both the fee and key to you and me respectively when the date arrives. The system works on the If-Then premise and is witnessed by hundreds of people, so you can expect a faultless delivery. If I give you the key, I’m sure to be paid. If you send a certain amount in Bitcoin, you receive the key. The document is automatically canceled after the time, and the code cannot be interfered by either of us without the other knowing, since all participants are simultaneously alerted.”
But how do they really work? What are the steps to follow for effectively design a smart contract and publish it on the blockchain so it can start carrying out its functions?
The process to be followed is the next: In first place, the contract has to be coded. The programmer has to define the outcome that will be triggered once the contract is executed, and more importantly, what conditions have to be matched in order for this to happen.
In the previous example: IF the contract receives enough funds THEN the key to the apartment will be sent to the buyer. In second place, it has to be deployed to the distributed ledger. Once the contract is effectively published, it will be allocated in the public ledger, where it’ll be accessible for all the users of the system. Therefore, it will be ready to start sending/receiving funds. Finally, following the rules of blockchain, once the contract has been published, every execution will cause every node in the system to achieve an individual agreement of its results. The network will then be updated with a record of the results of that execution.
These results will be written and stored in the blockchain, and from that moment single party manipulation will be impossible. All centralized systems are susceptible to be decentralized through the usage of smart contracts. Loans provided by banks, title registries, voting systems, regulatory compliance, and royalties for artists… Virtually anything that requires of a strong security, identification and privacy can be optimized by transitioning to a platform that uses smart contracts.
Smart contracts have been used in: The energy sector, to issue payments between prosumers and consumers in ecosystems where the first ones sell their excess of energy to the second group. Peer-to-peer have a tremendous potential in decentralizing the energy sector, empowering the consumers and opening the market for competition. Insurances, cutting down administrative costs and reducing the time needed to issue the payment. Also the usage of smart contracts allows to link the software to databases and sensors measuring parameters such as wind speed or magnitude of earthquakes, data that is recorded in the blockchain and triggers the outcome of the smart contract when surpassing the determined threshold.
Patents and copyright, A smart contract proving the ownership over something secured with copyright, like a song in the music industry, would ensure that the holder receives the royalty fee every time the content is used for commercial purposes. This is also used to secure ownership over real state. Internet of Things, In an era where everything goes towards a global interconnectivity, smart contracts are a key enabler for it. Each contract can call out data for multiple databases, and trigger if needed, the execution of other multiple contracts. Entire processes can be structured through a succession of smart contracts.
For example, keeping track of a package that has been sent, each sensor forms its own node on a blockchain and smart contracts can record “possession” of the device to each individual sensor, and subsequent location. A barcode / NFC chip / other tracking device on the package will be read at each sensor on the way to your house. Each time it is read by a new sensor, its location is broadcasted to and agreed on by all the IoT participants on the blockchain. As each recording of the package’s location is encrypted into the blockchain in a specific order, there is no securer system for tracking packages.
A smart contract then keeps tabs of “possession” all the way along the line, solidifying the trust of exactly where to find the package. The tremendous potential motivated that countless smart contracts started getting published in different ecosystems, most of them using different protocols and certainly different cryptocurrencies. In addition, they were written in different programming languages, creating a non-uniformous mass. The sector was calling for unification.