Smart contracts are self-executing contracts that are stored on the blockchain, written in the form of code, that power the functionality of NFTs. This may seem technical and irrelevant to an end user, but understanding smart contracts can help you make more informed decisions about NFT creation and collection.
What’s ‘smart’ about smart contracts?
Smart contracts are ‘smart’ because they can automatically calculate and process payments, and automatically carry out the terms of the contract. Every time a transaction is made, the code checks for certain conditions and performs the relevant actions.
Compared to traditional contracts, smart contracts process transactions and remittance near-instantaneously. There’s no paperwork to be processed, no chance for mistakes to be made, no money to be paid to middlemen. Because they’re stored on the blockchain, they’re highly secure and transparent. This means that smart contracts make the process of selling assets and facilitating transactions more secure and efficient.
Infographic from Blockgeeks
Can a Smart Contract be Changed?
As with everything else on the blockchain, smart contracts cannot be modified once they are created. This means that the NFTs you buy will never change or lose functionality.
Each smart contract also has a unique address on the blockchain that never changes. If you want to verify the authenticity of an NFT, all you need to do is check its contract address!
Functions of Smart Contracts
Among other functions, the NFT smart contract:
- Asserts ownership
- Manages permissions (whether an NFT can be transferred or resold etc)
- Secures payment and royalties
Let’s say you buy an NFT artwork in a secondary sale. The smart contract will take your payment, check that it’s the right amount, and transfer it to the seller. Out of this amount, it will calculate the amount of royalties that go to the original creator, according to the percentage set when the smart contract was made. It will then transfer the ownership of the asset to you.
This is a very basic example of a transaction, but smart contracts have many more capabilities. One that you may encounter is whitelisting, which grants certain permissions to a selected group of users. Some NFT projects use whitelisting to give their followers early access to drops, as a reward for participation in contests or other community events.
More complex functions of smart contracts are used in NFT games. The CryptoKitties game allows players to collect, trade, and breed virtual cats. Each CryptoKitty has a combination of different features, and built into the smart contract itself is a genetic algorithm that determines the inheritance and random mutations of the bred kitties.
The functionality of a smart contract depends on what is written into it during creation. In theory, it can do anything that can be written into the code, but cannot communicate externally to the blockchain. NFT smart contracts also adhere to the ERC-721 standard that defines the required functions of NFTs and allows them to interact with applications in predictable ways.
If you’ve been looking at NFTs, you’ve probably seen the term “ERC-721” somewhere. ERC-721 is a token interface standard that is used specifically for non-fungible tokens. But what does that mean?
When you buy an NFT artwork, your token doesn’t just contain the image, but also a smart contract which determines the functions of the NFT that allow applications to interact with it. These functions need to be standardised so that all NFTs can be used in the same way. If every NFT smart contract uses different functions with different names, applications won’t know what to look for! This is where ERCs come in.
ERC stands for Ethereum Request for Comments, and they are standards for tokens on the ethereum blockchain. An ERC standard is essentially a set of rules that all tokens of that type must adhere to. This allows developers and applications to easily interact with tokens because they know what to expect.
For example, the ERC-721 standard requires all tokens to be non-fungible, and have unique token ids. Most other standards such as the ERC-20 standard used for ethereum (ETH), do not have this requirement. This is why ERC-721 is the main standard used for NFTs.
Types of NFT Standards
ERC-721 – This is the standard for NFTs and was the first non-fungible token standard to be developed on Ethereum. Most NFTs follow this standard.
ERC-1155 – This standard allows both fungible and non-fungible tokens in the same contract. It is used mainly in gaming, because games have fungible assets like in-game currency, and non-fungible assets like unique items.
As you can see, different standards mean different token properties and capabilities. Knowing about the different standards means you don’t have to be able to read code, or understand the technicalities of smart contracts to understand what your token can do.