History and the potential of smart contracts
You may be surprised that the idea of smart contracts is older than Bitcoin. Nick Szabo was the first man on the planet who mentioned the term smart contract in 1994. Notice that at that time, there was no decentralized blockchain network. In his work, Nick Szabo described smart contracts in the following way:
A smart contract is a computerized transaction protocol that executes the terms of a contract. The general objectives of smart contract design are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries. Related economic goals include lowering fraud loss, arbitration and enforcement costs, and other transaction costs.
The key observation is that a smart contract is able to execute the terms of the contract and, at the same time, minimize the need to trust intermediaries. At this point, Szabo’s perception of smart contracts meets with the concept of decentralized blockchain networks that appeared in 2009 thanks to Bitcoin. A decentralized blockchain network is a trust machine that is able to transfer trust from people to machines. Thus, it can be used as a base infrastructure for the execution of smart contracts.
Smart contracts are much more effective and useful when they have the same properties as transactions that are sent in decentralized networks. It makes nearly no sense to have smart contracts on servers where administrators could change them or delete them. A smart contract can establish trust between two parties only in a decentralized world where both parties rely on the same infrastructure and neither of the parties controls it.
It was Ethereum that brought the idea of smart contracts to life in 2014. It was necessary to create an engine that would be able to execute a smart contract. The engine is called a virtual machine. It is a piece of software that runs on every full node in the network. Smart contracts are written by a programming language. The first one was Solidity that allows writing smart contracts for Ethereum Virtual Machine.
The simplest life cycle of a smart contract can look like this. A developer writes a smart contract in Solidity. You can imagine that as a simple program. The program can work with a few addresses and expect some inputs in order to make some decisions that can result in manipulation with assets. Firstly, the smart contract must be written then it is compiled and deployed. The developer needs to send the compiled smart contract into the blockchain via transaction and pay a fee. The smart contract is distributed to all full nodes in the network. At this point, we can say that the contract has been deployed and it can be executed by the network. The contract expects some inputs in order to change its state. As the state changes over time, the contract comes into the finalization state meaning the execution will end.
This type of programmable logic that is commonly referred to as smart contracts is a great extension of the concept of decentralization. Bitcoin is able to unconditionally transfer value from Alice to Bob. Ethereum allows them to add some additional logic. Thus, a transaction can settle only when and a certain condition is met.
The first web browser allowed you to open a web page and see the text. Nothing else. When Javascript and other extensions were added, you could log in, download content, or even transfer a value via internet banking. The capabilities of web browsers grow every year due to innovations. If we compared Bitcoin with the first web browser then projects like Ethereum or Cardano are the needed extensions that allow us to use decentralized technologies for many other things.
What is a smart contract?
In general, a contract is a written or spoken agreement, especially one concerning employment, sales, payments, or tenancy, that is intended to be enforceable by law. An agreement can be perceived as a set of conditions and actions. A fulfillment of a condition is to be followed by an action. For example, when Alice fulfills a condition then Bob is expected to act as he promised in the beginning. More iterations can be necessary to fulfill all conditions. In the case of disputes, a third party is defined that will resolve them. The goal of smart contracts is to digitize agreements and in the ideal case avoid the involvement of third parties.
As we said, a smart contract is a piece of code that a developer programs for a particular situation. The smart contract will be distributed from one node to other nodes by the network to be stored in the blockchain. Similarly, as a new block is distributed. The whole network is responsible for the execution of the smart contract and validation of results.
A smart contract can serve one party, two parties, or a group of people. For example, Alice and Bob can safely swap two digital assets without the risk that the counterparty does not fulfill a promise. A smart contract can serve as a custody service that will hold the firstly sent asset and make the swap only when both assets are available in the expected amount. A smart contract can also easily serve a group of people for example for a transparent collection of funds with the ability to refund participants in the case the majority will wish it.
A smart contract is a set of conditions and expected events that triggers actions. Upon the receipt of an expected trigger or input, the smart contract will execute and perform its assigned actions. Let’s return to our example with swapping assets. Both Alice and Bob are expected to send their assets to particular addresses. The smart contract expects that to happen in order to swap assets. Sending assets is the trigger that results in swapping them. The smart contract distributes swapped assets to new owners. There can be a condition in the smart contract, that is triggered by elapsed time. Thus, the smart contract is able to evaluate its state after a period of time and also perform an action. Thus, if only Alice sent the asset, the smart contract will return the asset back to Alice. The swap will not take place. Notice that Alice can be protected in the case Bob does not fulfill the promise. And vice versa.
Every active smart contract has a current state. During the execution, states are changed based on events. Smart contracts are processed from the start state till the end state. There can be several arbitrary states during the processing. You can imagine it as RAM in a computer. The current states of active smart contracts are shared across the entire decentralized network and stored in the blockchain. In other words, every node has a copy of the states of smart contracts.
Smart contracts cannot be altered by anybody. There is no way to covertly manipulate their content. Once a smart contract is deployed there is no way to change conditions or actions that have been programmed by a developer. There is also no room for distortion or false interpretation. The execution is deterministic. Outputs of smart contracts are produced deterministically based on inputs.
Benefits of smart contracts
Smart contracts are able to reduce counterparty risk. Counterparty risk is the likelihood or probability that one of those involved in a mutual agreement might default on its contractual obligation. Counterparty risk can exist in credit, investment, and trading agreements or transactions. Smart contracts allow people from around the globe to transact with one another without needing an intermediary, reducing the costs of middlemen and brokers. Due to smart contracts, financial interactions can be more complex and reliable.
Cardano will be responsible for storing data, states of smart contracts, and execution. It reduces the risk of data loss or manipulation. Smart contracts are executed autonomously and only participants are directly responsible for providing inputs that will move the smart contract to the next state.
A significant challenge for smart contracts is to reduce the need to involve third parties to participate in law enforcement. In many cases, it will be possible. A smart contract cannot obviously enforce the law in the physical world. However, it can reduce the need of using third parties for law enforcement. Participants can define punishment conditions in the smart contract. Thus, they can be motivated to fulfill promises. For example, Alice and Bob will need to lock $1000 worth of stable coins into the smart contract custody before swapping of assets will take place. If one party fails to send the asset in time then it can be punished by taking away the locked $1000.
Imagine how complex a task it could be in the real world. Parties would have to find a trusted third party. Third-party would have to understand the agreement and verify all data including KYC/AML. In the case of disputes, the third party would have to collect data and ask authorities to resolve the issue. It could be a long and expensive process. In the case of smart contracts, conditions and due dates are fixed and unchangeable. Parties either act as the contract expects or they can be punished right away.
Will smart contracts be a game-changer?
In our view, smart contracts will be a game-changer. If you think about the abilities of a decentralized network and the reasons why they are so useful you can come to a conclusion that besides others there is only one strong reason. It is the ability to define rules that are globally available, unchangeable, unstoppable, same fair for everybody. Monetary policy is a rule. The way how transactions are processed is a set of rules. Mining rewards or staking rewards are also rules. The power of decentralization is about the properties of these rules.
Smart contracts technology is a way to extend the ability to define rules. Rules can be customized for a given purpose that will fit the needs of smaller groups. For example, a smaller group can decide to issue their own tokens or coins with their own monetary policy. It can be inflationary or deflationary coins and a given group can decide to use them for payments. In the case of Cardano, it is not necessary to use a smart contract for issuing tokens. The group can use smart contracts for driving monetary policy or for building a set of rules. We can imagine that a monetary policy can be driven by collective voting.
At the moment, it is too early to think big and foresee this type of usage. On the other hand, it could be very useful for groups that wish to be independent and autonomous. Imagine a modern company that will issue tokens and defines a set of rules via smart contracts. For example, tokens can be used for voting and also for payment of dividends. Hypothetically, such a company could exist fully independently on states or authorities and could be local or global.
Binance and BNB tokens are very close to that idea. BNB is perceived as shares of Binance. Binance promised to regularly burn BNB tokens but it happens in a centralized way. Thus, rules can be easily changed. Imagine that a smart contract would be deployed that would take care of the burning of BNB tokens. The process would be transparent and holders could have additional rights regarding governance. Cardano can be used for this type of usage.
In reality, there would be a few hurdles. For example, Binance is probably a legal subject in given jurisdictions. The CEO can refuse to hand over critical private keys or other credentials. It will take some time to create a new form of a fully decentralized company with the ability to take away critical rights to one leader and give them to another one. One day, it will be probably technically doable.
Conclusion
The first thing we see on Cardano will probably be decentralized exchanges. Swapping digital assets is the simplest thing we can do. Smart contracts technology is just one building stone and we need more of them to bring more useful functionalities. We need identity management systems to be able to work with identities. We also need Oracles to link digital and physical worlds together. At the moment, we are in the early stage and everything is under development. Alonzo hard-fork will bring smart contracts to Cardano. Atala Prysm is the identity management for Cardano and it will help to bring so far unseen functionalities.
Bitcoin was never intended to replicate the current financial systems. It is evident that the first layer will probably never be the payment layer. The most important thing about Bitcoin is the monetary policy. One rule saying that there will never be more than 21M of BTC coins. We will need more rules if we want to build a new decentralized world. These rules must be inclusive. It means that it must be cheap to follow these rules. Blockchain networks are globally available but it does not necessarily mean that it is easy or cheap to adopt the rules and believe in them. Cardano will be a global financial and social operating system that allows us to define our own rules which we want to follow and it will be cheap, fast, and easy to adopt them.
Decentralized Finance (DeFi) would never exist without smart contracts. The concept is sound and promising but what we need is to improve the user experience and reliability. Cardano has the potential to bring the world of DeFi to ordinary people who either need it or want alternatives to the traditional financial systems. We need to step out of the small cryptocurrency lake and step into the big world of finance. People will not study the beauty of blockchain and decentralization but they might be interested in new financial services and products.