Smart contracts will significantly impact how people, machines, and organizations operate and transact in the future. They’re also crucial building blocks of many applications using
blockchain technology.
Below, you’ll find exactly what smart contracts are, what they do, and how they work. You’ll also learn about all the different use cases and the pros and cons of smart contracts. They are still in their infancy, and a lot still has to be figured out, but the implications are likely far-reaching.
What is a smart contract?
A smart contract is computer code executed when certain conditions are met. A good example of a smart contract is a
vending machine. When you buy something in a vending machine, the code in the machine analyzes how much money you put in, what you picked, what it has in stock, and how much change it has, then decides if you’re getting your money back or if you’re getting what you picked and how it will give out your change all without needing a person, like a cashier, there.
Nowadays, smart contracts are mostly used with blockchain technology in the
cryptocurrency world. They create tokens through ICOs, mint NFTs, and take crypto loans.
Ironically, smart contracts are neither “smart” nor “contracts.” They’re not smart because they won’t do anything besides what they’re programmed to do. And they aren’t like traditional contracts because they’re not legally binding. Not yet, at least.
Historical background
Nick Szabo developed the concept of “smart contracts” in a 1994 paper. The well-known computer scientist and cryptographer defined a smart contract as “a computerized transaction protocol that executes the terms of a contract.” He aimed to bring traditional contracts to the digital world while minimizing the need for trusted intermediaries.
The applications were minimal after Szabo first coined the term because you couldn’t create trustless and immutable smart contracts. This changed when Bitcoin was launched in 2009, and with it, digital currency and blockchain technology using a distributed ledger. You could create and deploy trustless and immutable smart contracts for the first time.
It was still a challenge, though, since Bitcoin Script, the programming language used to write smart contracts on the blockchain, was not widely known. This made it harder for developers to program and easier for them to make mistakes.
This led Vitalik Buterin, one of Ethereum’s co-founders, to design the
Ethereum blockchain using Solidity, a new programming language that is much easier to use and read. The smart contract code will then be compiled and executed on the Ethereum Virtual Machine (EVM).
Ethereum is still the blockchain with the most prominent use of smart contracts; however, most current blockchains can also have smart contracts.
How do smart contracts work?
Smart contracts are generally "if/then" statements written in code. With the right inputs, a certain output is guaranteed. This code is then deployed on a blockchain so users can interact with it. Once it is on the blockchain, it is immutable, it can’t be changed.
Not clear? Imagine you’re buying a house. You could create a smart contract that executes when certain conditions are met and deploy it on a public blockchain like the Ethereum blockchain. Open-source templates often used for smart contracts can be easily found on the internet. As conditions, you and the seller could agree that when 100 Ether is paid, you’ll receive the digital deed to the house. All without an intermediary like a notary or real estate agent. The transaction costs for buying a house are drastically reduced.
Now, smart contracts can only read what is on the blockchain. So, if a smart contract needs external data like the outcome of a sports event, confirmation of successful payment, the temperature of the day, or the number of votes a candidate got to determine if the conditions for executing the contract are met, the data from the outside world needs to be brought to the blockchain. This is where oracles come in.
Oracles is a third-party service that feeds data from the real world to smart contracts on the blockchain, triggering predefined actions. The biggest challenge, however, is trusting the data source. Various approaches are being explored to make oracles resistant to false information.
Smart contracts use cases
Finance
A common use for smart contracts is found in
Decentralized Finance (DeFi). Decentralized exchanges,
staking, yield farming, derivatives, flash loans, collateralized loans,
stablecoins, providing liquidity. They all work by using smart contracts.
Besides DeFi, traditional banking is also busy testing all the applications of smart contracts. Many of the financial services provided by banks could soon be provided through smart contracts. Barclays said smart contracts are set to reshape the business world.
Insurance
An insurance company could automate the release of claim money when certain conditions are met, like when a flight is delayed or canceled. A car insurance company could create an insurance plan that only charges a user when he is actively driving the vehicle. The rates could change in real time based on where and under which conditions customers are using their vehicles.
Supply chain
Through smart contracts, paper trails and the need for approvals at every step can be reduced. It reduces fraud and loss. Smart contracts can also be used for inventory management and payment automation.
Government
Smart contracts could provide a more secure voting system and increase voter turnout. Additionally, documents like a driver’s license could be sent out once all conditions are met and payment is made.
Real estate
Let’s say you want to rent a house. A smart contract could be written so that you receive the digital key to the house as soon as you transfer enough cryptocurrency to it. As long as the payments are made on schedule, the owner of the digital key gets access to the house. The digital deed would be transferred via a smart contract when buying a house.
Healthcare
Personal health records could be encoded and stored on the blockchain network with a private key that grants access only to specific individuals. Surgery receipts could be automatically sent to insurance providers as proof of delivery.
Pros and cons
Immutability: Once it is on the blockchain, the smart contract can’t be changed anymore.
Safety: Through cryptography, the blockchain is kept secure from hacking.
Permissionless: Anyone can write a smart contract and deploy it to the network.
Speed: Once the conditions are met, the contract is executed immediately.
Savings: By removing the need for third parties, the cost of transactions is reduced.
Trustless: There is no need to trust a third party like a bank. It works exactly as coded and is saved on the blockchain.
Immutability: If there are bugs in the contract, the vulnerability can be exploited. In the DAO hack, $60 million worth of Ether was stolen through an exploit.
Trust: If you can’t read and audit the code yourself, you’ll often find yourself trusting it just because others do, or because you trust whoever deployed it on the blockchain.
Regulation: Uncertainty on how the government will regulate smart contracts.
Change: Since smart contracts are immutable, any change in the contract means a new contract needs to be deployed.
The bottom line
Smart contracts are a perfect example of Amara’s Law, which states that “we tend to overestimate the effect of a technology in the short run and underestimate the effect in the long run.”
Smart contracts are already beginning to replace middlemen. While most of the applications listed above are visionary and still need development, once smart contracts evolve and become more widely adopted, they will likely revolutionize how people and machines transact in ways we can’t yet imagine.