These past few months, Finiam has been getting more involved in the Web3 scene. Our latest client, dissrup.com, allowed us to deep dive into dApps and NFTs. I'm going to share some of what I've learned.
So this blog post is a clarification of NFTs for developers or anyone with a moderate understanding of programming. I noticed that many people (including me) always had difficulty comprehending much of this blockchain, De-Fi, Web3 stuff. After some months of working on an NFT project, let me share what I think are some of the most crucial tech aspects of NFTs.
So, what's an NFT exactly?
Wikipedia states plainly that an NFT is a "unique and non-interchangeable unit of data stored on a digital ledger (blockchain)". Pretty cool stuff. But what does it mean for a regular developer?
To understand what an NFT is, perhaps we should talk about blockchains and smart contracts. But I'm not going to do that. Our focus is to understand NFTs. If you want to learn more about blockchains or smart contracts, you can check this quick video for an intro on smart contracts.
The blockchain of choice for NFTs is usually Ethereum. It's by far the most popular blockchain that supports smart contracts, even though some others, like Solana, are on the rise.
In short, a smart contract is a program that you can embed inside a blockchain. Every time you interact with a smart contract, each interaction is stored immutably on the blockchain. The immutable and decentralized nature of blockchains is what locks in the proof of ownership of NFTs. In traditional Web2 systems, like most of the apps we use today, our data is stored on a server exclusively owned by the company that provides said service. Said company can tamper with your data as they see fit, guaranteeing absolutely no rights on the ownership of your data.
Once you store something on a blockchain like Ethereum, it’s impossible for someone to remove that stored data. You can alter the state of the blockchain, like transferring an NFT or Ethereum tokens to someone, but all of the updates are incrementally stored on that said blockchain.
Given the inherent financial nature of all blockchains that allow smart contract execution, you can trade NFTs for money in the blockchain itself, giving way to decentralized marketplaces that revolutionize the way artists can get rewarded for their work. Essentially, blockchains allow you to programmatically move money around without depending on 3rd parties like PayPal, thus, ensuring a decentralized marketplace.
But, how do NFTs show up in the first place? NFTs are created by special smart contracts that follow either EIP 721 or EIP 1155 (more on this one later). EIP (also ERC), or Ethereum Improval Proposals, are like smart contract standards to enable common functionality. Imagine these EIPs kind of like abstract classes, like those you see on object-oriented programming courses. If your smart contract implements all of the functions defined on the standard, you can create NFTs and trade them and sell them with other people with Ethereum addresses.
The proposal states that each NFT has a unique ID and maps to a given URL. Said URL has the content of the NFT, be it an image or any other media asset. Example of a metadata entry:
{ "name": "Awesome NFT", "description": "My amazing NFT", "image": "https://link.to.my.image.com" }
The smart contract defines the mapping of token ID to the metadata through a function called function tokenURI(uint256 _tokenId) external view returns (string);
. Most smart contracts usually have some mapping like https://my.api.com/:tokenId
, where they store their data on a centralized database and resolve it with a custom HTTP API. Others keep the NFT metadata on IPFS, which is usually the consensus for true decentralization.
The EIP calls for the tokenUri
because storing images and large amounts of text on the Ethereum blockchain is super expensive. And with the never-ending valuation of the Ethereum token, this price will go up. So, we need to resort to 3rd parties for the storage of our data.
Some obvious misconceptions
Many hardcore NFT fans claim that blockchain technologies revolutionize the ownership and longevity of artworks by using fully decentralized technologies. Both of these aspects are in part true, but most NFT businesses don't truly put in the work to achieve this, not because they don't care, but because it's challenging.
A valid criticism, and a trendy one, is that an NFT is just proof that you own a receipt that points to an URL. True. Another valid complaint following up on that is that if the server that serves that URL is gone, you lose the artwork behind your NFT. Also true.
Even IPFS does not solve that. IPFS is an Interplanetary File System. It's a network of storage nodes that act as a global, immutable file system. Every time you upload something to IPFS, the network assigns a content ID to your file (CID). This ID is immutable and will always map to the file you uploaded. As the content on IPFS is immutable, you cannot delete it.
The significant pain of IPFS is that you need to maintain your node to ensure that your uploaded data is not deleted. There is no free cake here. To use IPFS on your computer or server, you need to have a node. When you visit some marketplace and view an NFT, they usually request the NFT data from an IPFS gateway. They take a CID and ask around the IPFS network to see what node has the file, and then they display it back to you.
Most NFT projects use a pinning service like Infura or Pinata, where you can upload stuff to their IPFS nodes. You have to pay for it, though (every month usually), and if you stop paying, your data gets unpinned. In theory, any other node can keep that data for you, but nothing is guaranteed. Even if an NFT is stored on an IPFS, we still depend on the platform owners to pay for the pining services. Still, the community can operate nodes and pin the CIDs of the platform themselves, or maintain a community-owned IPFS node that guarantees the existence of those CIDs.
And, the smart contracts themselves would need to store the IPFS CID and not the actual URL to guarantee maximum immutability and safety. You can construct a regular URL using an IPFS CID like https://ipfs.infura.io/CID
but this should not be stored on the smart contract. Imagine that Infura stops supporting IPFS, and suddenly that entire smart contract no longer has any valid URL.
For 100% immutable and long-lived assets, you can use Arweave, a blockchain to store actual file data. Your assets stay there forever, provided you have an upfront fee for it. There is a proposal to remove assets from Arweave (if you are the owner), but it's still one of the better ways right now to store data permanently.
Is there any use other than quirky profile pictures?
The hype around NFT is built around the various communities of highly valued avatars like Crypto Punks and Bored Apes. Many people criticized the energy waste and usefulness of such projects. Is there anything NFTs are worth other than that?
The answer is yes, it is. One of the coolest ones is ENS domains. ENS is to Ethereum what DNS is to the Internet. It maps a domain name, like finiam.eth
to a given Ethereum public address. Not only that, but you can also associate other information to that address like an avatar or Twitter handle, being ENS a domain name infrastructure tool and an overall internet identity tool.
ENS domains are also ERC-721 NFTs, so that transferring the NFT behind your ENS domain to another address gives complete control of the domain to that address. By being NFTs, ENS domains unlock the ability to operate a decentralized domain marketplace without strings attached. DNS registrars can turn private consumer-owned domains into large corporations if enough money is on the table. With ENS, none of that happens, and if anyone wants your domain, they can place a bid on OpenSea, and then you get to decide what to do. You 100% genuinely own your domain, and nothing can take that away from you.
The same thing happens on social media networks, known to turn over handles and usernames to anyone with millions in cash. ENS is a groundbreaking movement for Internet identities, and it's using NFTs for that.
But it's still a tremendous amount of energy for simple data storage
Yes, it is. At the time of writing this, the Ethereum blockchain consumes as much energy as the entirety of Kazakhstan (in December 2021). It's a lot, and in the middle of a catastrophic climate crisis, there is nothing much to be said about it other than it sucks. Proof-of-work systems have no place in the ecosystem right now. Right now, Ethereum 2.0 aims to reduce Ethereum energy consumption by 99%. Still, it’s a considerable effort to migrate an entire system like Ethereum. The target date for the migration is Q2 2022.
Elon Musk said the problem is not the energy spent by the various proof of work blockchains but their source. Even if blockchains are using 100% clean energy, that’s still energy that people could use to heat/cool their homes and whatnot. Proof of work systems are slower than the alternative. If cryptocurrencies aim to break through, we need better than 13 transactions per second and confirmation times in the range of minutes.
There is plenty of more energy-efficient (and faster) blockchains, like Tezos, Polkadot, Solana, Cardano. These blockchains all support smart contracts, which means NFTs can be implemented there. Bonus points for the fact that transaction costs, the equivalent of gas fees on Ethereum, are pretty cheap there too.
There are also energy-efficient sidechain solutions, where you have an EVM-compatible blockchain on top of Ethereum. By being EVM compatible, you can deploy any Solidity smart contract that would work on Ethereum to that sidechain. Polygon (Matic) is one of the most popular ones. You can also easily migrate assets, like NFTs or ETH tokens, to the mainchain (Ethereum).
Summing things up
NFTs are a valid technology solution like many others, with many exciting features and business models, but with many cons, like all new tech. Both its supporters and critics are very polarized right now, as it is the norm for social interactions on the Internet right now. Personally, I think it’s a cool technology, with clear downsides like unusable gas fees and extraordinary environmental costs. Still, it’s a step in the right direction for the decentralization of the web and increase in transparency, if done in the right way. As with all new technologies, we are still trying to figure out the best practices for the ecosystem, so, as always, stay informed if you can!
Stay safe everyone! 👋