Smart Contracts: What Are They and How Do They Work?
Wondering what smart contracts on the blockchain are, how smart contracts work, and what smart contracts are used for? Learn everything you need to know.
What is a smart contract?
In the simplest terms, smart contracts are programs built on blockchains, that execute a specific action when certain conditions are met. You can think of smart contracts as a self-executing program. When conditions are met between two parties, a smart contract will automatically perform a given action, without any need for a third party or intermediary.
How do smart contracts work?
So we know smart contracts are programs, so just pieces of code, stored on the blockchain. Without getting into coding terminology - smart contracts use simple stipulations to perform a given function based on certain conditions, known as if-then statements.
The if statement sets the conditions of the contract, while the then statement determines the action taken if the conditions are met. A great example of a simplified smart contract is a vending machine. If you insert a dollar and press A1, then you’ll get the treat in the A1 slot.
But with smart contracts, these if-when statements can set conditions and actions for a huge number of agreements. While currently, smart contracts are mostly used in the DeFi market for financial products, their potential application in the future could extend to many markets including retail, real estate, medical, and more.
What are some examples of smart contracts?
Some examples of existing smart contracts on the blockchain include:
Uniswap: Uniswap is a popular decentralized exchange that allows users to trade crypto directly from their wallet, without the need for a centralized crypto exchange, as all trades are executed using smart contracts.
Compound: Compound is a decentralized lending and borrowing protocol - so users can loan crypto to earn interest or borrow crypto with collateral without a third party as all funds are held in liquidity pools and transactions are automatically executed using smart contracts.
Lido: Lido is a liquid staking solution for PoS blockchains like Ethereum, Polygon, and Solana. The protocol lets investors stake crypto without losing liquidity, as investors receive tokens representing their staked assets in return, which they can then invest in other protocols. As with other protocols, Lido uses smart contracts to execute all transactions automatically.
What are the benefits of smart contracts?
There are many benefits to smart contracts, including:
Speed & efficiency: Automation and a lack of intermediaries speed up transactions.
Cost: Eliminating the need for third parties also brings costs down, theoretically saving investors money on things like trading fees. However, this isn’t always quite the case as if the given network you’re using is congested, you may still pay high gas fees for transactions.
Transparency: Like everything on the blockchain, transactions executed by smart contracts are recorded on the public ledger, so anyone, anywhere can view the transaction details. As well as this, the code for the vast majority of smart contracts is open-source.
Security: Thanks to predetermined conditions - provided the code for the smart contract is sound - they provide a high level of security for transactions as unless certain conditions are met, the given transaction will not go ahead.
What are the risks of smart contracts?
Despite their benefits, smart contracts still face some challenges, including:
Code vulnerabilities: Smart contracts are only as secure as their code. If there are errors or vulnerabilities in the code, smart contracts may have security breaches. Perhaps the most infamous one was the attack on The DAO in 2016, where someone exploited a vulnerability in the code and stole funds, eventually leading to a hard fork for the Ethereum blockchain in order to refund users.
Scalability: Network congestion presents a significant problem for smart contracts and Ethereum is a prime example. During the initial DeFi boom, as more and more protocols were built on the Ethereum blockchain, these new investment opportunities attracted more and more investors. As such, the Ethereum network became congested and investors saw record-high gas fees - hitting as high as $196 in May 2022.
Legal uncertainty: Smart contracts are a new technology and, currently, largely unregulated. Should smart contracts begin to gain traction in other regulated industries, it is likely governments around the world will inevitably look to bring in legislation and regulations.
Smart contracts vs. written contracts
Smart contract | Written contract |
---|---|
Fully automated | Processed by humans |
Immutable | Mutable |
No third party | Intermediary parties |
Recorded on public ledger | Private physical or digital document |
Which blockchains support smart contracts?
Ethereum is the most well-known blockchain with smart contract support, but it’s far from the only blockchain that supports smart contracts. Many other blockchains support smart contracts including:
What could smart contracts be used for outside of crypto?
While smart contracts are primarily used for crypto transactions currently, their potential application in other industries is vast. Just a few examples of where smart contracts may be able to revolutionize other industries include:
Music industry: Smart contracts could help make getting royalty payments or stream payments easier, faster, and fairer.
Supply chain management: Self-enforcing contracts could theoretically become end-to-end supply chain contracts with no need for manual management and audits.
Real estate: Smart contracts could change the way property ownership works entirely, removing the need for manual contracts written by solicitors and creating self-executing contracts that change home ownership.
FAQs
More questions about smart contracts? Here are your answers.
Does Bitcoin have smart contracts?
Yes. The Bitcoin blockchain upgraded to include smart contract capabilities with the Taproot upgrade.
Can you make smart contracts without coding?
Yes. There are some programs that allow you to input your desired smart contract capabilities and the program will generate the code for you/ As well as this, some users have reported success at using AI programs like ChatGPT to generate code. However, you’ll need to make sure your code is sound before you deploy it, as well as audit it for any security vulnerabilities.
What’s the future of smart contracts?
The sky is the limit. Smart contracts could theoretically revolutionize many industries by automating processes that once took extensive human oversight.
How do smart contracts make money?
Smart contracts themselves don’t make money, but protocol developers usually charge users a small fee for using a given platform. This fee then pays relevant stakeholders, as well as often being split between liquidity providers who help provide the collateral for the platforms to run.
What is an NFT smart contract?
An NFT smart contract is a piece of code built on a particular blockchain that manages transactions relating to non-fungible tokens.
Are smart contracts legal?
Smart contracts are a new concept that haven't had much attention from governments yet, and they’re currently predominantly used in an unregulated market. As such, smart contracts have no clear legislation or regulation yet.
What companies are already using smart contracts?
Some companies outside the crypto world using smart contracts include real estate company Propy, invoice financing company Populous, and Fizzy AXA, an automated flight refund company.