A smart contract is a computer program stored on a blockchain that automatically carries out the terms of an agreement once certain conditions are met.
A blockchain is a digital record of transactions that is securely copied across multiple computers at once. This helps ensure that no single company, bank, or government is in control.
Because the smart contract runs on the blockchain, it can eliminate the need for an intermediary to facilitate a transaction.
The aim is to streamline processes and secure them. Once information is entered into the blockchain, it’s difficult to change or remove, so it also provides transparency for the parties involved.
Here’s how a smart contract might look in practice.
A retailer agrees to pay a supplier $20,000 when a shipment arrives. Instead of the retailer manually approving the payment, a smart contract holds the money and releases it as soon as the shipment's delivery is confirmed.
The retailer and supplier have already set the terms in advance, so neither company has to rely on the other to approve and release the payment.
How Does a Smart Contract Work?
A smart contract follows the same basic life cycle.
It’s Written
A developer writes the rules of the contract in code as "if this happens, then do that" instructions on a blockchain.
It’s Posted
The finished contract is published to the blockchain, where anyone with access can view it. In many cases, the rules can’t be changed once the contract is deployed.
A Transaction Triggers It
The contract waits until someone interacts with it. In the example of the retailer and supplier, the payment is triggered when delivery is confirmed.
The Network Executes It
Thousands of computers run the code and agree on the result. The outcome is recorded on the blockchain and no single party can alter the record.
Why Smart Contracts Matter to You
The big promise of smart contracts is that they save time and money by automating tasks and cutting out the middleman. That can benefit consumers too.
A traditional escrow account for a home or business sale can take days to settle and involve fees for holding the money. A smart contract can process the payment a lot faster, and it runs around the clock, including weekends.
A travel insurance company can also use a smart contract. If a flight is cancelled, the airline can provide that information to the contract. As soon as the cancellation is confirmed, the insurer can automatically pay the customer who bought the policy.
That way the customer doesn't have to file a claim and wait for an insurance employee to review and approve it.
The code in smart contracts is also usually public, so you can see exactly what the rules are instead of trusting a company's fine print.
Many other industries are using smart contracts, including:
Decentralized Finance
Decentralized finance, or DeFi, includes apps that let you lend, borrow, and trade crypto through smart contracts instead of a bank or brokerage.
A lending app, for instance, can automatically collect interest from borrowers and pay it to lenders without a loan officer involved.
Stablecoins
A stablecoin is a cryptocurrency designed to hold a steady value. It’s usually tied to a stable asset, such as the U.S. dollar. Ideally, stablecoins should combine the fast transactions and low fees of crypto with the stability of traditional currencies.
Most major stablecoins are issued and tracked on blockchains using smart contracts. They’re widely used in DeFi for trading, lending, and hedging against crypto market fluctuations.
Digital Ownership
Non-fungible tokens, or NFTs, use smart contracts to record who owns a unique digital item, such as artwork, a concert ticket, or an in-game asset.
Tokenized Assets
Tokenization means representing a real-world asset, like a share of stock, a fund, or a slice of real estate, as a token on a blockchain. Smart contracts can be used to issue, transfer, and manage the token.
What Are the Risks of Smart Contracts?
Despite their efficiency, smart contracts do come with risks, often human-generated..
Coding Bugs
If someone writes bad code, the contract can malfunction or be exposed to security vulnerabilities.
No Undo Button
Because of the hard-to-change nature of blockchain, a coding error can be difficult or impossible to reverse. A smart contract may need to be scrapped and a whole new one written.
Dependency on External Sources
A blockchain can’t see the outside world on its own. In the retailer example, the shipment’s delivery has to be confirmed by an oracle, a service that feeds real-world information into the blockchain.
If the oracle reports bad data, the smart contract will follow its instructions anyway and could release the payment incorrectly.
