What Is A Smart Contract And How Does It Work?
Bitcoin laid the foundation of a truly decentralized peer-to-peer currency. However, the Bitcoin protocol isn’t very flexible and it can only deal with transfer of value and allows you to create scripts for complex transaction types. Vitalik Buterin, one of the pioneers of the Ethereum blockchain, wanted to extend the functionality of Bitcoin to build applications on top of it.
However, Bitcoin protocol is closely tied to the underlying consensus rules that makes it almost impossible to add an application layer on top of it. After doing the research, Vitalik Buterin and his team created the Ethereum blockchain that can support not only the transactions but has an execution environment for running applications.
These applications are deployed through ‘smart contracts’, which are programs that are stored on the blockchain, and can run once the predetermined conditions are met. On a granular level, you can think of Ethereum as an App Store where you can deploy different applications with one or a series of smart contracts.
How Do Smart Contracts Work?
Let’s understand this with an example. A developer wants to deploy a simple application that takes the collateral from a borrower, and lends him a certain amount of funds. He will write the code (the code is actually the smart contract) and deploys that to the Ethereum blockchain. The developer will then build a simple website or a mobile application that interacts with the smart contract to perform lending and borrowing operations.
If Alice wants to take out a loan, she will go to the website and request a loan. The website will interact with the smart contract and ask Alice to send a collateral to an address. Once the smart contract receives the collateral, it will release the loan to Alice. Everything will be recorded on the Ethereum blockchain, and there will be no intermediaries like a bank or a financial institution.
This is the simplest form of a lending and borrowing application. It can be extended to P2P lending where lenders deposit their funds in a smart contract that can approve and release the loans once the collateral is received. The smart contract ensures that the interest goes directly to the lenders, and in case of a default, the lenders can get the collateral to minimize loss.
Simple P2P lending through smart contracts | Source: Lendoit
Smart Contract Platforms
The smart contract based applications on the blockchain are called decentralized applications, or dApps. Ethereum is the biggest smart contract platform in existence, and almost every dApp is deployed on Ethereum. The second biggest smart contract platform is EOS, followed by Tron, based on the number of smart contracts deployed.
Each platform has a different approach towards building and running smart contracts, but the core logic remains the same. Smart contracts are just programs that run on the blockchain. Just like a regular computer program, they take the instructions as an input, and produce a desired output.
Top 3 smart contract platforms | Source: State of the dApps
Smart Contract Applications
Smart contracts set a cornerstone for entirely new industries on the blockchain such as Decentralized Finance (DeFi) that includes blockchain-based financial applications without any central intermediaries. DeFi is all powered by smart contracts, and has many different applications for lending and borrowing, payments, synthetic assets, derivatives, and decentralized exchanges (DEX).
DeFi has grown to become a $100 billion industry, and as of writing, more than $80.95 billion of value is locked across various DeFi protocols. This locked value represents the amount of assets that are currently being staked in a specific DeFi applications (e.g., lenders provided funds to the lending application, people buying synthetic assets, etc).
Total value locked across various DeFi protocols | Source: DeFi Pulse
Let’s discuss some of the largest real-world applications using smart contracts to deliver financial products and services to the masses.
Lending and borrowing: Aave is the largest lending and borrowing application built on the Ethereum blockchain that uses smart contracts. Unlike traditional P2P lending where lenders have to interact with the borrowers, Aave uses lending pools where lenders can deposit their funds in a pool managed by smart contracts, and borrowers can take out a loan from the lending pool after depositing the required amount of collateral.
Synthetic assets: Synthetix is a platform on Ethereum that uses smart contracts where you can buy on-chain synthetic assets that track the value of real-world assets such as commodities, stocks, indices, and other derivatives.
Exchange: Uniswap is a decentralized exchange (DEX) that allows you to swap Ethereum-based ERC-20 tokens. Uniswap uses smart contracts to manage everything from the asset pricing to token swap and liquidity pools.
Closing Thoughts
Smart contracts are just programs, or a piece of code, that runs on the blockchain. In a global world where trade often occurs between parties that don’t trust each other, smart contracts offer a great solution that ensures contract execution, and enable users to trade between themselves in a trustless manner without the involvement of any central intermediary.
Sign up on KuCoin, and start trading today!
Follow us on Twitter >>> https://twitter.com/kucoincom
Join us on Telegram >>> https://t.me/Kucoin_Exchange
Download KuCoin App >>> https://www.kucoin.com/download
Also Subscribe to our Youtube Channel >>> Listen to 60s Podcast