Smart Contracts
September 1, 2021What is a smart contract?
Smart contracts are becoming very popular, and sometimes, the concept of smart contract seems to be much more abstract or complicated than it actually is. There are many ways to define a smart contract, but in this post I will try to use simple and understandable definitions.
A smart contract is a piece of code which contains a set of functions, somehow similar to a traditional API. These functions contain business rules which are executed under certain conditions when they are called. To put an example, let's define a smart contract which contains some functions. One function returns the balance of a particular token of the requestor. There could be another function which allows the user to transfer his funds to another user. There could be another function which allows the user to give permission to another user to transfer his funds to someone else. These are just simple examples to facilitate the understanding of what a smart contract is, but as you can imagine, the potential is almost infinite. Smart contracts can interact between them, creating really complex logics behind.
Where are smart contracts?
Probably you associate smart contracts with blockchain technology, right? There is a good reason for it. What I described above is just a simple program, but what makes smart contracts so special?
Smart contracts are a perfect use case for blockchain. If you think about it, blockchain offers certain properties which are a complete must for smart contracts, but before talking about these properties, first we need to understand what decentralization means.
What is a decentralized platform?
To understand what a decentralized platform is, let's first clarify what a centralized platform is.
Data is becoming key nowadays. You are constantly consuming data in your daily basis, even if you are not aware of it. When you navigate through the internet, when you use social media, when you check your balance in your bank, when you pay with your credit card... you are surrounded by data, digital data which is stored somewhere. Now, where is all these data stored? The data can be stored in your computed, in your mobile, or in a remote server. Either if the data is stored locally in one of your devices or if it is in the cloud, in the end is stored in a computer (or group of computers) which are owned by someone. To put an example, all the information you exchange via WhatsApp is stored somewhere, and Facebook has the keys to access this information, or to stop the service anytime. The information is centralized on Facebook.
Decentralization is the opposite. Decentralization means that the data is split across all the world. Everybody has the rights to participate in the network, and each participant will have a copy of the data. Protocols are making sure you don't need to trust anybody, once again, the code is law and every single participant follows the protocol's rules. To put an example, if you own a unit of value, for instance, 1 Ether, this record is existing in all the nodes participating in the network. There is a global consensus on your property of this Ether. On the other hand, you are the only one who has the keys to send this Ether to someone else, and nobody in this planet can do anything about it, no matter how much power. As you can see, this is true property, protected by protocols.
Blockchain properties
Now is the moment to explain these key properties which will help you understand why smart contracts are running in decentralized platforms, typically on the blockchain.
Immutability
Would it make sense if people could change the business rules once they are defined? Obviously not, otherwise smart contracts could be manipulated by those with the right power to do it, exactly as in a traditional system. That's why immutability is key. Nobody has the power to change the rules once they are in production, no matter who they are.
Censorship resistance
Another key property to make sure nobody, including governments, can censor these rules. In order to censor a truly decentralized smart contracts platform, you should make sure all nodes which are part of the network are shutted down, which is really unlikely to happen. To put an example, if China's government forbids these activities, the participants could either go somewhere else to keep going with their business, or simply shut down their computer which would not crash the system.
Transparency
Decentralized platforms are normally open, and everything is forever tracked in the blockchain. Records cannot be modified, and everybody can check the transactions and the state of a smart contract. Information cannot be manipulated, it is what it is, crystal clear and forever. To put an example, the number of existing Ether is perfectly known, it is public. This is different from the amount of circulating Dollars, Euros or even gold.
Security
The blockchain uses advanced cryptography techniques to secure all the activities, making sure there is no possibility to cause, for instance, a double spend (same token spent twice). Until today, all vulnerabilities found in these platforms are due to poor logic when coding smart contracts, but the blockchain protocol itself is completely secure. To put Ethereum as example, nobody was able to double spend any single Ether until today, or to break any rule in a smart contract.
Interruption-free
Because these platforms are decentralized, and many nodes are running them, it can never be interrupted. If 1.000.000 computers are participating, it means these 1.000.000 should be shut down for the blockchain to be interrupted. The more decentralized a blockchain is, the more difficult to shut it down.
Trustless
We all know that you cannot trust everybody in this world. When there is any activity which requires a group of people to interact, you always need to trust someone else. If you do any business with someone else, you must either trust him or trust a third party who makes sure everything goes well. In this case, protocols are making sure the law is respected, which means you can be involved in any kind of operation without having to trust anybody. The code is law, and you know exactly what will happen under determined conditions.
Use cases for smart contracts
Nowadays, the most relevant and successful uses cases with smart contracts are DeFi and NFTs.
DeFi means decentralized finance, and this industry is building a set of applications powered by smart contracts called decentralized applications or DApps. The purpose of these applications is to provide access to anyone with connection to internet to the financial markets without centralized authorities who can deny your access or block your payments.
NFT means non fungible tokens. A non fungible token is a unique digital asset with unique properties. This is getting a lot of traction in the digital art. This means an artist creates an NFT, which in the end is a piece of digital art registered on a blockchain (mainly on Ethereum).
Of course there are many use cases being used and explored, such as digital identity, insurance, supply chain management, clinical trials and much more.
Conclusion
Although you cannot see smart contracts still in the media and most of the people don't know what they are, the adoption is exponentially growing. Year after year, thousands of users are joining this ecosystem and new use cases are popping up, showing us alternatives to the existing and limited system. The more our knowledge about smart contracts is getting deeper and deeper, the more we can see how they are going to change the world. At this moment Ethereum is the main platform running smart contracts, but there are more platforms getting traction and nobody knows where this is going to get us... maybe to a world governed by protocols? Maybe, or I would say, probably.