Put simply, smart contracts are agreements that can be written in computer code. They are stored on the blockchain so they can be tracked and authenticated.
Think of them like a regular legal contract, but instead of a lawyer, the computer upholds the terms. This means there’s no need to trust a middleman as the terms are coded in and non-negotiable.
Smart contracts are one of the most innovative mechanisms to hit us in the 21st century. They are the backbone of Web3, DeFi and the majority of crypto as we know it.
How do smart contracts work?
A smart contract may include an instruction written in code that says:
“if X happens, do Y.”
It will trigger a particular action if the pre-decided terms have been met.
Both parties involved in the transaction must agree to the terms. If the contract terms aren’t fulfilled, for example, if neither X nor Y happens, the contract won’t execute.
Smart contracts can be super simple. For example, I give you $100, and you pay me back $5 every day for 24 days (4 days representing interest). Or, I give you $100 of Bitcoin, and you pay me back $5 daily in Ethereum.
In these cases, the code can verify that both parties can fulfil the agreement. If programmed to do so, the smart contract will check to see that both sides have the money they need. It can lock this up, automating payments between the parties.
A more complex example: you give me $100, and I pay you back $5 daily in Bitcoin + 6% paid in interest paid in Ether.
In a smart contract, almost anything is possible. If you can think of logical terms that can be written down, they can also be put into a smart contract. In fact, because of the connectivity (with smart contracts being connected to wallets, protocols and more), many things that weren’t possible through traditional contracts are now possible.
What are they used for?
Often, smart contracts act as digital agreements that allow the transfer of crypto without the need for a middleman. Once the agreement has been decided, the smart contract will check that its terms have been fulfilled. Then the crypto assets will be exchanged.
As they allow actions to be completed without an intermediary, they are also essential to the DeFi (decentralized finance) space. An example is setting a limit order on 1inch (a decentralized exchange aggregator). You set the price you want to buy the asset. The smart contract automatically buys the asset for you if the asset reaches that price.
Smart contracts power popular platforms like Ethereum, Cardano, Solana, and Polkadot, and all protocols that are built on top of them.
What are the benefits?
- Secure: cryptography ensures records cannot be altered
- Autonomous: they operate automatically, saving time
- Transparent: anyone can view the smart contract on public blockchains
- No-intermediary: there’s no need for a middleman to verify information as the blockchain does it
What are the weaknesses?
It’s important to note that smart contracts aren’t always perfect. Sometimes for security, developers choose to make the smart contract uneditable. This means that once launched, they cannot be updated or altered, which can lead to issues in the future.
And while they are secured by blockchain technology, their design also needs to be secure. Otherwise, errors in their code may be exploited.