Deploy on IPFS
Non-fungible is an economic term used to describe things that are unique and not interchangeable with other things of the same type. The concept behind non-flippable tokens is that they are not only unique, but that their uniqueness can be easily verified through a public record on the Blockchain. When a digital asset, say a single still “photo.jpg” file, is added as an NFT to the Ethereum Blockchain, a common misconception is that the actual bytecode of the file “photo.jpg” after a block is written. With transactions and on-chain data alone, the Ethereum blockchain just crossed the 1TB mark today, so you can imagine if every single NFT jpeg, gif and movie file was added, it would quickly balloon to petabytes of data. Given that the primary motivation for Blockchain is decentralization, if the chain grows to this size, it would be prohibitively large for most nodes to maintain, leaving a more centralized network of big boxes.
Instead of storing the NFT data files in the chain, the NFT instead has an immutable tokenURI record that points to a file. If this tokenURI uses location addressing like a conventional web server, e.g. http://myserver.com/photo.jpg then it’s pointless to have an irrevocable tokenURI record if the file at the address destination can just be eliminated, which is exactly what happened to some unfortunate NFT owners.
This is where IPFS comes in. The InterPlanetary File System is a peer-to-peer distributed storage network, not unlike BitTorrent, made up of computers around the world that store and share data. IPFS also uses a cryptocurrency called FileCoin as an incentive layer so that users are rewarded for storing data on their computers. The main difference here is that instead of using location addressing like conventional websites, IPFS uses content addressing, which involves generating a hash (“CID”) of the file or directory and using it for retrieval.
Location Addressing: http://myserver.com/photo.jpg Content Addressing: ipfs://QmP7u9UzoUtfpiNkj3Sa…
To access an IPFS content from a web browser, you use a gateway like ipfs.io provided by Cloudflare, e.g.
https://ipfs.io/ipfs/QmP7u9UzoUtfpiNkj3SaL5TLym2ngrUfvsiNhf21uFF3L1
The beauty of using IPFS for NFT data is that not only is it decentralized and always on, but if a single byte in a file changes, the CID changes. This means that the immutable tokenURI of the NFT record is always guaranteed to return exactly the same data.
Before you start uploading the data to IPFS, there is one more consideration: the metadata used to display the NFT. Rather than setting the tokenURI of the NFT to point directly to the file on IPFS, you instead point it to a metadata JSON file on IPFS, which includes information about the NFT and in turn points to the source file as well as any additional files such as as a preview image. Because this metadata file is also stored on IPFS, you can be sure that it has not been modified either. There is no official Ethereum specification, but the format described by OpenSea has become standard.
To get the files onto IPFS, you can download the Desktop application and use it to upload the complete source directory, including the index.html, the genomic data, the javascript, the supporting libraries, and the preview images. Note that the file paths within the index.html do not need to use content addressing (the IPFS port can resolve location addressing at the directory level), but for this reason they must be relative.
With the data now on IPFS, you then copy the CID from the directory and the image preview files and complete the entries in the metadata.json files. Finally, you upload the metadata files and copy the CID that will be used with the NFT. Note that the tokenId=1001 parameter passed to the index.html is simply used as a sequence number so that the single source directory can generate the 3 different variations (species) depending on the URL referenced in the metadata.
{“token_id”: 1001,”name”: “Capcicum annuum”,”description”: “This red pepper depiction was generated…”,”image”: “ipfs://QmYpZF5D95THTiF4gVuUuze46eA4SHjwWEZBvFXSn7GE2k/annuum”, “background_color”: “fcf5e5″,”external_url”: “https://nicetotouch.eth.link/peppers”,”animation_url”: “ipfs://QmYpZF5D95THTiF4gVuUuze46eA4SHjwWEZBvFXSn7GE02k/attribute”1estokenIindex.html”, [{ “trait_type”: “Species”, “value”: “Capsicum annuum” },…]}
The IPFS Desktop application actually serves your files to the world, so they will only be available as long as your computer is running. To ensure that the files are always on and replicated to other peers (rather than just cached temporarily), we need to “pin” them. There are a few different pinning services out there, but I chose Pinata which gives you 1GB for free and is extremely simple to use. Simply register, click to upload/add and paste the CIDs you want to pin.
Disclaimer for Uncirculars, with a Touch of Personality:
While we love diving into the exciting world of crypto here at Uncirculars, remember that this post, and all our content, is purely for your information and exploration. Think of it as your crypto compass, pointing you in the right direction to do your own research and make informed decisions.
No legal, tax, investment, or financial advice should be inferred from these pixels. We’re not fortune tellers or stockbrokers, just passionate crypto enthusiasts sharing our knowledge.
And just like that rollercoaster ride in your favorite DeFi protocol, past performance isn’t a guarantee of future thrills. The value of crypto assets can be as unpredictable as a moon landing, so buckle up and do your due diligence before taking the plunge.
Ultimately, any crypto adventure you embark on is yours alone. We’re just happy to be your crypto companion, cheering you on from the sidelines (and maybe sharing some snacks along the way). So research, explore, and remember, with a little knowledge and a lot of curiosity, you can navigate the crypto cosmos like a pro!
UnCirculars – Cutting through the noise, delivering unbiased crypto news