Discover more from smol farm gazette
What the Heck is a Smart Contract?
The concept of a "smart contract" can be confusing at first. We look at what they really are — and why they have that name.
One of the more confusing concepts for newcomers in web3 is “smart contracts.” These are the backbone of how web3 functions, and yet its name is somewhat misleading at first glance. Contract conjures images of legal documents, but a smart contract is more akin to an “app” than anything — except everyone shares the same instance of it on the blockchain.
Each smart contract has a specified address — much like a regular cryptocurrency wallet. Smart contracts themselves also can maintain balances of crypto, though withdrawal is handled through smart contract code. Many web3 projects use “multi-sig wallets” that require multiple people to authorize each transaction — these are just smart contracts designed to securely authorize transactions in this way.
Every NFT is also associated with a smart contract. In some cases, such as with manually uploaded OpenSea NFTs, there will be a “shared” smart contract for numerous NFT collections. However, the industry has increasingly trended towards a correlation between smart contracts and NFT collections — one contract, one collection. In the case of EVM chains like Ethereum and Polygon, this is standardized through a variety of “ERC” — Ethereum Request for Comment — standards.
Most tokens on these chains use one of three ERC standards:
ERC-20 - fungible tokens, the “classic” sort of cryptocurrency where each token is interchangeable.
ERC-721 - traditional NFTs, where each token has unique data associated with it
ERC-1155 - editions NFTs, where each NFT can have more than one interchangeable copy
With each of these standards, the smart contract using them is expected to implement a standard set of functions. These are often provided by pulling in standard libraries from OpenZeppelin or the gas-saving ERC-721A implementation from the creators of Azuki. More user-friendly tools like Manifold also enable people to create boilerplate contracts for these sorts of assets that they themselves can own and control.
Smart contracts can implement any sort of function that can be coded in the supported languages — in the case of EVM chains, typically the TypeScript-esque Solidity or the Python-esque Vyper. This enables smart contracts to even function as read-only infrastructure. For instance, the popular Shields project for designing on-chain heraldry has read-only smart contracts that simply provide the data to render various shield elements on-chain. These can be called by the on-chain rendering code of any other contracts on the chain — as is done by the main Shields NFT collection.
All of this might seem overwhelming, though it can be summed up as: code that lives on the blockchain. This code often conforms to certain standards to enable the minting of on-chain assets like NFTs. So where the heck does the term “smart contract” come in?
One oft-repeated mantra in the cryptocurrency world is “Code is Law.” Whether you believe the idea or not — courts can compel people to do a lot of things that might go against the code — the idea is the smart contract automates the contractual elements of managing assets. The collection of royalties, rent, or taxes can be enforced through how the assets are represented in code.
For instance, many web3 users get ENS domains, which enable you to represent wallet addresses as a memorable, human-friendly name ending in .eth rather than a string of random hexadecimal digits. These domains exist as NFTs. However, the smart contract powering them requires them to be renewed periodically, or they will expire.
Some proponents hope that these will some day come to be used with major real-world assets as well, such as property deeds. Their property taxes — or for the fans of Henry George — land value taxes could be collected automatically, with provisions that enable them to revert back to the governing authority for protracted non-payment. However, we need to make some inroads in security as a society first, so people don’t “all my apes gone” their house from a phishing attack.
Smart contracts, at their simplest, are just code that lives on the blockchain, but the potential they represent is immense. Though publicly executable code is far from a new concept, their ability to provide tamper-resistant tracking of assets is what earns them their name. While most people will unlikely ever need to write one, understanding what they are is important for creators and collectors trying to break into this exciting new world.
Thanks for Reading!
smol farm gazette is an independent publication by smol farm. All proceeds go to support independent creators. Most content is free, and the rest — along with the ability to comment — is just $5/mo.