This week, we’re going to cover nearly everything about smart contracts. We are intentionally skipping over the specifics of writing and deploying contracts and are specifically avoiding the depths of Solidity.
Smart Contracts
By Harrison Smith, Research @ Future Mints
Contracts are of paramount importance in our society. The contract, a set of promises agreed to in a "meeting of the minds", is the traditional way to formalize a relationship. Contracts are used in business, marriages, politics, finance, social interactions, and nearly everything else.
There are four key facets of contract design seen time and time again in both contract theory and common practice:
Observability - the ability of participants in a contract to view each other’s performance of the contract.
Verifiability - the ability of a principal to prove that a contract has been executed or breached.
Privity - the principle that knowledge and control should be distributed only as is necessary for the performance of that contract (security and confidentiality).
Enforceability - the ability for a contract to be upheld, and the ability to find someone in breach.
Whether enforced by a government, or otherwise, contracts in the real world are upheld by third-parties that can serve as arbiter in the case of dispute. This way of settling disputes is what we are most familiar with in our modern world, and it is known as reactive enforcement.
Far better than reactive enforcement is a concept known as proactive enforcement. Optimal enforcement of contracts minimizes the need for enforcement at all by creating a system that has no need for dispute.
Enter, smart contracts.
Although smart contracts have gained popularity over the past few years, the concept is far from new. In fact, one of the first mentions of smart contracts spans all the way back to writings from Nick Szabo, a computer scientist who pioneered research into digital contracts and digital currency in 1994.
In Szabo’s words, “a smart contract is a computerized transaction protocol that executes the terms of a contract. The general objectives of smart contract design are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries. Related economic goals include lowering fraud loss, arbitration and enforcement costs, and other transaction costs.”
The basic idea is that many kinds of contractual clauses can be embedded into hardware and software, in such a way as to make breach of contract expensive or even impossible. Smart contracts are self-executing, meaning that there is no need for a third party, since the contract itself is ultimately the arbiter.
And those four key principles of observability, verifiability, privity, and enforcement? Smart contracts excel at all of those things.
While it may seem like it, smart contracts aren’t at all a foreign concept: think of vending machines. You put money in, you press your selection, and you get the item you wanted. The lockbox safely stores the cash, and prevents anyone from easily interfering with the contract. The enforcement of the transaction is reliant solely on the function of the code.
While there are endless examples of these “crude” smart contracts, the point is that the principles of smart contracts are not incomprehensible.
And in the business world, inanimate, paper-based contracts are increasingly becoming antiquated. Companies around the globe are switching to online contract platforms (such as Docusign), but these online platforms come with a problem - digital signatures often lack traditional notary procedures, which can cause headaches and even disputes.
Remember what I said earlier: proactive enforceability is always superior to reactive enforceability. And proactive enforceability is exactly what blockchain based smart contracts provide.
So when Ethereum was launched in 2015, it was the perfect storm of demand for exactly what Ethereum could offer. One of the key features of Ethereum is the Ethereum Virtual Machine (EVM) - software that runs on the blockchain that allows the implementation and execution of smart contracts directly on-chain.
Smart contracts are simply programs that run within the EVM. It's a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain.
Since smart contracts have addresses, they are innately a type of Ethereum account. According to Ethereum.org, “smart contracts are a type of Ethereum account. This means they have a balance and can be the target of transactions. However they're not controlled by a user, instead they are deployed to the network and run as programmed. User accounts can then interact with a smart contract by submitting transactions that execute a function defined on the smart contract. Smart contracts can define rules, like a regular contract, and automatically enforce them via the code. Smart contracts cannot be deleted by default, and interactions with them are irreversible.”
Smart contracts operate on a “if… then” framework. This framework has made things such as DEXs possible, enables the capacity for on-chain loans, and unlocks a multitude of other use-cases.
Compared to the text-based contracts of the past, smart contracts rely on code to explain the terms of the agreement. Ethereum smart contracts are written in Solidity, an object-oriented programming language for implementing smart contracts on blockchains.
Similar to traditional contracts, smart contracts can be used for a variety of different things. While it is possible to copy a smart contract (just as it is for a traditional contract), the purpose of the contract typically differs on a case-to-case basis.
Besides enabling identity proofs, what other real world impacts can smart contracts make?
We’ve used a similar example before, but imagine someone takes out a loan on a car. They fail to meet the payment terms, miss a few payments, and the creditor is now interested in repossessing the unpaid vehicle. While currently this would probably turn into a repossession battle, smart contracts solve this problem.
There are definitely quite a few hurdles to pass before we reach that point, but smart contracts are rapidly advancing, and will have increasing prominence throughout the world. Since Ethereum’s inception, we have seen smart contracts’ functions continuously evolve; the abilities smart contracts possess today are far greater than even researchers like Szabo probably predicted.
One of the biggest ways we’ve seen smart contracts evolve is through NFTs. While NFTs have existed in some capacity as long as Ethereum has been around, the capacities of NFTs have changed massively throughout that time.
Token standards are the set of rules, conditions, and functions that dictate how a crypto token work, and represent a guide for the creation, issuance, and deployment of new tokens.
When the first NFTs on Ethereum launched just a week after the blockchain’s deployment, they were without many of the key functionalities that we know today. By late 2015, the ERC-20 standard was implemented. There are six required functions in ERC-20:
TotalSupply — Used to derive the total token supply of a specific ERC-20 token.
BalanceOf — Used to derive the token balance in an Ethereum wallet.
Transfer — Allows the user to transfer the ownership of a token to another.
TransferFrom — Works similarly to the Transfer function, with the added advantage of allowing contracts to transfer tokens on a user’s behalf.
Approve — Used to set a limit on the number of tokens a smart contract can withdraw.
Allowance — Grants external addresses the access and permit to spend the tokens from a certain balance.
There are a few other non-required, yet essential functions such as Token Name, Ticker Symbol, and Divisibility.
While ERC-20s were never intended to be used for NFTs, developers were obviously able to make it work.
Two years later, ERC-777 would release, effectively serving as a backwards-compatible upgrade to the predecessor. ERC-777 addressed efficiency, and enabled new capabilities such as the power to blacklist certain addresses.
While these two functions were both built primarily for fungible tokens (tokens where every single one is the same, such as BTC or ETH), ERC-721 was built and intended specifically for non-fungible tokens.
From Ethereum.org:
Just as ERC-777 was a sequel to ERC-20, ERC-1155 would soon after become the sequel to ERC-721. ERC-1155 notably allowed for batch transactions, which drastically mitigates gas issues when minting or transferring NFTs.
You can see the effects of these token standards throughout the blockchain, and you can look further into the specifics of any token contract directly on Etherscan.
Throughout the development of these standards, Ethereum has solidified itself as the premier destination for token environments of all forms.
And smart contracts are the vessel that made all of it possible.
Wrapping Up
Szabo pretty much nailed it. Smart contracts have flourished throughout the blockchain space since their inception, and they will continue to evolve into ways that we can’t even imagine today.
I also think it's a bit ironic that Szabo specifically clarified back in 1996 that “no use of artificial intelligence is implied” in smart contracts. And now, nearly 30 years later, artificial intelligence systems have been used to create smart contracts and tokens.
Lastly, of course, there are inherent risks when using smart contracts. If you don’t read the terms of a smart contract, you expose yourself to risks just as you would with a normal contract. Similarly, a malicious actor could publish and disperse a smart contract that’s entire purpose is to steal your assets. There are platforms such as Dexscreener that can help you determine the reliability of various smart contracts, but ultimately the only way to know is by reading the contract language for yourself.
As always, stay safe, and we’ll see you next week.
News of the Week
Coinbase opened up the bridge for their new layer-2 network, Base, on Thursday. The official launch is slated for August 9th, and will kick off “Onchain Summer,” a series of events in which creators and developers can make art or build applications on Base.
Global golf community LinksDAO has released new membership tiers to join its community of golf enthusiasts. The new tiers of membership offer various levels of access to the group's private Discord, network of peer-to-peer private courses and eventual entry to its Spey Bay Golf Club in Scotland.
Curve, a stablecoin exchange at the heart of defi on Ethereum, has been the victim of an exploit according to a tweet from the project. More than $100M-worth of cryptocurrency could be at risk due to a bug in the Vyper compiler.