If you’ve heard much about blockchain, chances are that you’ve heard about smart contracts. But what makes smart contracts, well, smart? In this article, we dive into what smart contracts are, why they’re critical to any Web3 project, and give real-world examples of their applications.
Simply put, a smart contract is a piece of code that runs on a blockchain. Much like any other contract, it establishes and enforces the terms of an agreement. Smart contracts allow developers to codify an agreement in a secure, transparent, and accessible way to anyone. From loans to logistics to insurance, smart contracts are how agreements are enforced on Web3 platforms.
To understand why smart contracts are important, let’s take an example of how a traditional contract works. Let’s say that you take out a loan to buy a car. Before you can purchase your new car, the bank or other lender will give you a lengthy legal contract that spells out all the terms and conditions of the loan, including the interest percentage the bank will charge, the amount of time you have to pay back the loan, and what happens if you fail to repay the loan.
Now, let’s say a year later that you realize that the bank has been overcharging your interest on the loan. Sometimes, the bank will rectify the situation and pay you back the amount they overcharged. But what about the case where the bank doesn’t do anything? You’d have to hire a lawyer and bring this claim to court. In court, your lawyer would explain how the bank did not follow the terms of the contract to prove that they charged you more interest than you agreed to.
Does that all sound complicated (and expensive)? Well, that’s because it is.
In Web3 applications, developers write smart contracts to the blockchain so that they are enforceable. These agreements are public and objectively enforced by the network, not a third party like a court or other mediator. By enforcing the agreement in a decentralized manner, both smart contract creators and users of the smart contract can rely on the terms of the agreement without needing to trust each other. Why is this? For the most part, smart contracts cannot be updated after they are written (with some exceptions).
Smart contracts allow developers to build a variety of applications that efficiently replace current systems that require expensive and time-consuming contract enforcement (think finance, legal, and other complex applications).
The concept of smart contracts dates back to the 1990s when Nick Szabo compared them to the functionality of a vending machine. Let’s say you wanted to purchase a can of soda for one dollar, but you only have a five-dollar bill. When you insert your five-dollar bill, you expect the machine to either give you the soda and four dollars in change or return your five dollars if the soda is sold out.
This may seem like a trivial use case, but this logic is programmed into the vending machine. And whenever we use a vending machine, we trust that this is the behavior that the vending machine will follow.
Now, let’s tie this into how smart contracts work. When using a vending machine, you must trust that it will do what you expect. When using a smart contract, you are guaranteed that the contract you are using will perform exactly as you expect. Smart contracts are publicly verifiable and trustless, meaning the logic of the smart contract can be viewed by anyone, and the blockchain itself is responsible for executing the contract, not the contract creator.
To understand how this works in practice, let’s continue with our vending machine example:
Every token created on the Enshrine platform uses the Enshrine smart contract. This contract is written to the Polygon blockchain and controls what token owners can do with their tokens.
Among other functionality, the Enshrine contract enables:
The short answer is: yes. But let’s explore why smart contracts benefit creators (as well as token owners).
Imagine you’re an artist that enjoys painting the dogs that you see when you’re out on a walk. Now let’s say that you want to sell your paintings and ensure that you receive 5% of the sale price every time someone sells your artwork. Without something like a smart contract, you’d have to rely on the honor system and trust that whoever is selling your art sends you a royalty payment. This sounds pretty unlikely, right?
As we discussed earlier in the article, smart contracts are permanent once written and are enforced by network consensus. This means that you can guarantee that any time someone resells your painting, you’ll receive 5% of the proceeds from that sale.
By using smart contracts, creators don’t need to rely on any platform or individual. Regardless of where their tokens are sold or who is reselling them, they can depend on the smart contract logic behaving precisely as they expect it to. As we see it, this gives more power to creators because they can be less reliant on platforms and a new avenue to monetize their content on their terms.