This is the second piece in our series on decentralized finance, known as DeFi. In our initial piece we introduced the concept of DeFi, examined its core elements (the smart contract, the token and the exchange), and took a look at DeFi’s growing impact. In this installment we’ll take a deeper dive into the first core element, the smart contract, which is the backbone of DeFi.
The ability to run a smart contract is one of the features that separates a cryptocurrency system like Ethereum from that of Bitcoin. Bitcoin’s intended purpose is to be a peer-to-peer electronic cash system. While Bitcoin is famously volatile and occasionally subject to network congestion, it has proven to be largely successful, and many consider it to be revolutionary. It is good, and getting better, at what it set out to do.
If we think of the Bitcoin blockchain as a pocket calculator, then the Ethereum blockchain—and its native currency, ether—is more like a computer: capable of handling many types of applications. Anyone can write lines of code to the Ethereum blockchain and submit a transaction with inputs and commands to run those lines of code. These lines of code are called smart contracts.
One benefit of smart contracts is that everything is in the open. The code, transactions and outputs are all written to the public Ethereum blockchain, and anyone can verify that that the execution of the code was correct. This feature allows counterparties to enter into programmable transactions that settle in accordance with the code without others having to even know who the counterparty is.
Here’s an example of how it works based on a prediction market called Augur, which is one of the first uses of smart contracts in dApps on Ethereum:
John and Tom both hold ether. John thinks ether will go down in value in the future and would like to hedge against his position. Tom believes ether will go up in value and would like to add leverage to his position. John and Tom could send their ether to a smart contract to accomplish their individual goals. The smart contract is open-source and both parties can inspect its terms. John does not have to trust Tom, or even know him. If one party doesn’t deposit the appropriate collateral, the other’s is returned. Alternatively, the smart contract may stay open until the counterparty position is filled.
Once both parties have contributed their ether, the smart contract would hold the combined ether until an agreed-upon maturity date, much like a futures contract. On that date the smart contract will then automatically check an agreed-upon price oracle and distribute the appropriate amount of ether back to John and Tom. If ether went up in value, Tom would receive more than he contributed. John would receive less, but the same value in terms of dollars. Settlement is final and nearly instantaneous.
More advanced smart contracts can operate as fully functioning dApps—which may need to rely on real-world data to execute as intended. This brings us to the concept of an oracle, which serves as an agreed-upon source of truth. It is a data feed that links the blockchain to the real world, providing external and executable information. Creating an oracle can be as simple as coding a dApp to check ESPN for sports scores or USPS for confirmation of delivery. There are also blockchain-based oracles like Chainlink, which serve to decentralize the function of the oracle, making it more tamper-proof.
The gross value of assets locked into smart contracts has been growing exponentially. According to data from DeBank and The Block, there is currently more than $75 billion locked into Ethereum-based smart contracts, with another $25 billion locked into other smart contract-enabled blockchains. A year ago, there was less than $10 billion locked into all smart contracts.