What Is a Smart Contract?

Do repost and rate:

Smart contracts are a key component of Decentralized Finance and have numerous applications in non-cryptocurrency related businesses as well. But what is a smart contract? In this article, I want to provide a brief overview of what a smart contract is, why smart contracts matter, and how you can get started with smart contracts. 

What Are Smart Contracts?

Let's start off with a basic definition of a smart contract. My own non-technical definition is that a smart contract is essentially a contract that is automatically executed if certain conditions are met. To understand why smart contracts are such a big deal, its best to understand why contracts themselves are important. A contract is basically an agreement between at least two parties to do something. Your rent and lease agreement is a contract. Your mortgage loan is a contract, and even betting your friend $5 that the Patriots will win the Super Bowl is a form of a contract. The problem with traditional contracts is that we can't ever be 100% sure that the other party is going to hold up to their end of the bargain. Renters sometimes pay late (or not at all), mortgage borrowers default, and friends sometimes "forget" that they made a bet on a sports team.

Smart contracts remove this uncertainty of traditional contracts by assuring that the contract is fulfilled if a certain event happens. Let's take the dumb contract where you and your friend bet $5 on the Patriots winning the Super Bowl. To turn this into a smart contract, we'd need some way of ensuring that if the Patriots win, you get the money, and if they don't your friend gets the money. This could be done by each party depositing $5 into a locked box. If we had the required technological skill, we could program a bot to scrape internet news feeds so it would know which team won and then send a code to the phone of the user who guessed correctly so that they could open the box and claim the prize. It's not a perfect example, but the takeaway is that using this smart lock box would mean that only the right person would get the funds under the right conditions.

Cryptocurrency Example

Those of us who write on PUBLISH0X or Uptrennd know that we have to manually request our crypto withdraws. This is a good example of a traditional contract. The staff has to manually approve the withdraw and send the funds. You can see that my most recent withdraw from Publish0x progressed through several phases which required manual intervention by a human to receive, approve, and then send my funds. 

I want to be clear that there is nothing wrong with using manual approval for rewards, and many other sites, such as Uptrennd, do the same thing. And although I have complete confidence in the Publish0x team to honor withdraw requests, let's speculate for a minute and see how a manual process could go wrong. For one, the staff could refuse to pay rewards. Maybe some staff member wants to keep the funds for themself, or maybe they just don't like me, but they could refuse to pay out the funds. Secondly, the staff might want to pay rewards but might be unable to do so because they are overwhelmed by the volume of withdraw requests. Suppose that the price of BAT skyrockets to $10 and everyone rushes to withdraw and convert to fiat before the price crashes or that Publish0x swells to 10X its current user base. That is 10X more withdraws that the team has to process. Again, the point here isn't to criticize Publish0x, or any other site that uses manual withdraws, rather, it is to show the inherent limitations of traditional contracts. Traditional contracts require us to trust the other party and can be slowed down by human intervention. 

By contrast, smart contracts increase trustless by decreasing the need for human intervention and improve efficiency and speed through automation. I can deposit Dai into Compound Finance and earn interest bearing cDai by interacting with the contract. This cDai is given to me not by some protocol administrator, but rather, it is minted by the contract itself as a direct consequence of me depositing funds into the protocol. I don't have to worry about some corrupt administrator taking my Dai and not giving me the cDai in return. The contract itself guarantees that each party receives their end of the agreement. At the same time, I don't have to wait for manual deposit or withdraw approval. Because no human is needed to process the transactions, large increases in the number of users can be accommodated much more easily than with manual systems. 

Getting Started

Just as traditional contracts are written on pieces of paper, smart contracts exist as lines of code in a computer program. Smart contracts don't exist in and of themselves. Rather, they exist as a set of instructions (computer code) on some blockchain. Therefore, creating smart contracts means writing code that is able to interact with the blockchain.  If you want to get started with smart contracts, you first need to know what blockhcain you want to operate on as this will determine which programming language you need to learn. For example, Solidity is the smart contract language of Ethereum and Tron, C++ is the language of EOS, and SmartPy is the language of Tezos. Personally, I'm most excited about the implementation of Cashscript, which is the smart contract language of the Bitcoin Cash blockchain. It doesn't have the same renown as Solidity or C++, but I'm excited to see where it goes. 

There are a few ways to get started writing your own smart contracts. You can take free courses on Udemy. Or, if you'd rather have more of an interactive adventure, you can try CryptoZombies to learn Solidity (Ethereum/Tron). If Tezos is your preferred blockchain, you can check out Cryptoverse Wars and learn SmartPy (Tezos) while fighting off aliens.

Summary

The main takeaway from this article is that smart contracts are automatically executed if the required conditions are met. An example of this is when the Compound contract automatically mints cDai when you deposit Dai. Because these smart contracts are executed automatically, they reduce the need for human intervention and approval. As a result, smart contracts increase trustlessness and also increase efficiency through automation. 

Image Credit

https://unsplash.com/@sctgrhm

 

Regulation and Society adoption

Ждем новостей

Нет новых страниц

Следующая новость