What Is a Smart Contract and How Does It Work?

Smart contracts will have a major impact on how people, machines, and organizations operate and transact in the future. They’re also crucial building blocks of many applications being built using blockchain technology.
Below, you’ll find out exactly what smart contracts are, what they do and how they work. You’ll also learn about all the different use cases as well as 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, which is 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 the need of having a person, like a cashier, there.
Nowadays, smart contracts are mostly used with blockchain technology in the cryptocurrency world. Creating tokens through ICOs, minting NFTs, taking a crypto loan, are all done through the use of smart contracts.
Ironically, smart contracts are neither “smart” nor “contracts.” They’re not actually smart in the sense that 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

The concept of “smart contracts” was developed by Nick Szabo in a paper he published in 1994. The well-known computer scientist and cryptographer defined a smart contract as “a computerized transaction protocol that executes the terms of a contract.” In essence, his objective was to bring traditional contracts to the digital world while minimizing the need for trusted intermediaries.
After Szabo first coined the term, the applications were still minimal because you still 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. For the first time, you could create and deploy smart contracts that were trustless and immutable.
It was still a challenge though, since Bitcoin Script, the programming language used to write smart contracts on the Bitcoin blockchain, was not widely known. This made it harder for developers to program and easier to make mistakes.
This led Vitalik Buterin, one of Ethereum’s co-founders, to design the Ethereum blockchain to use Solidity, a new programming language much easier to use and read. Smart contract code would 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 have the capability of having 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, then you’ll receive the digital deed to the house. All without an intermediary like a notary or real estate agents. 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 are 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 the need to trust 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 the automation of payments.

Government

Smart contracts could provide a drastically more secure voting system and maybe even increase voter turnout. Additionally, documents like a driver’s license could be sent out as soon as 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 as soon as you transfer enough cryptocurrency to it, you receive the digital key to the house. As long as the payments are made on schedule, the owner of the digital key gets access to the house. Or when buying a house, the digital deed for the house would be transferred via a smart contract.

Healthcare

Personal health records could be encoded and stored on the blockchain network with a private key which would grant access only to specific individuals. Receipts of surgeries could be automatically sent to insurance providers as proof-of-delivery.

Pros and cons

Pros
  • 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.
Cons
  • 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, and 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.

Reclaim Up to $610/Year in Car Insurance

Here’s the thing: your current car insurance company is probably overcharging you. But, who has the time to look around for around a new company?

A website called CarInsurance.net makes it super easy to see if you’re getting the lowest price. All you have to do is enter your ZIP code and your age, and it’ll show you your options.

Using CarInsurance.net, people have saved up to $610 a year.

It takes just a few minutes to see how much CarInsurance.net could put back in your pocket. And the best part? Because we’re driving less, some insurers are slashing prices this month.

Share this article

RECOMMENDED POSTS
What is Inflation and How Does It Affect You
October 15, 2021
What is Inflation and How Does It Affect You
How to Get Out of a Car Lease
October 06, 2021
How to Get Out of a Car Lease
Forbes 400 Richest People in the World
October 06, 2021
Forbes 400 Richest People in the World
The Cost of Raising a Child, State by State
September 23, 2021
The Cost of Raising a Child, State by State
Start Making Money Moves