Читать книгу DeFi and the Future of Finance - Campbell R. Harvey - Страница 16
THE SMART CONTRACT PLATFORM
ОглавлениеA crucial ingredient of DeFi is a smart contract platform, which goes beyond a simple payments network such as Bitcoin and enhances the chain's capabilities. Ethereum is the primary example. A smart contract is code that can create and transform arbitrary data or tokens on top of the blockchain to which it belongs. Powerfully, it allows the user to trustlessly encode rules for any type of transaction and even create scarce assets with specialized functionality. Many of the clauses of traditional business agreements could be shifted to a smart contract, which not only would enumerate but also algorithmically enforce those clauses. Smart contracts go beyond finance to include gaming, data stewardship, and supply chain.
Ethereum charges a gas fee for every transaction – similar to how driving a car takes a certain amount of gas, which costs money. Imagine Ethereum as one giant computer with many applications (i.e., smart contracts). If people want to use the computer, they must pay for each unit of computation. A simple computation such as sending ether (ETH) requires minimal work to update a few account balances and thus has a relatively small gas fee. A complex computation involving minting tokens and checking various conditions across many contracts requires more gas and thus will have a higher fee. The gas fee may lead to a poor user experience, however. It forces agents to maintain an ETH balance to pay it and leads to worry about overpaying, underpaying, or the transaction not taking place at all. So initiatives are ongoing to eliminate gas fees from end users. There are also competitor chains that completely remove this concept of gas.
However, gas is a primary mechanism for preventing system attacks that generate an infinite loop of code. It is not feasible to identify malicious code of this kind before running it, a problem formally known in computer science as the halting problem. Suppose a car is on autopilot, stuck in full throttle with no driver. Gas acts as a limiting factor: the car will stop eventually when the gas tank empties. In the same way, gas fees secure the Ethereum blockchain by making such attacks cost-prohibitive. They incentivize highly efficient smart contract code since contracts that use fewer resources and reduce the probability of user failures have a much higher chance of being used and succeeding in the market.
On a smart contract platform, the possibilities rapidly expand beyond what developers desiring to integrate various applications can easily handle. This leads to the adoption of standard interfaces for different types of functionality. On Ethereum, these standards are called Ethereum Request for Comments (ERC). The best known of these define different types of tokens that have similar behavior. ERC-20 is the standard for fungible tokens and defines an interface for tokens whose units are identical in utility and functionality.2 It includes behavior such as transferring units and approving operators for using a certain portion of a user's balance. Another is ERC-721, the non-fungible token standard, which are unique and often used for collectibles or assets such as peer-to-peer loans. The benefit of these standards is that application developers can code for one interface and support every possible token that implements that interface. We will discuss these interfaces in more detail later on.