Maker of Things
Published in

Maker of Things

hic et nunc // updatable NFTs using IPNS

hic et nunc is an NFT platform based on the Tezos blockchain. The main thing know is it is way more environmentally (and artist) friendly than those based on Ethereum.

Warning: I still don’t quite understand how IPFS/IPNS works. It seems that you have to keep your IPFS daemon up and running (along with your computer) or loading OBJKT may fail on Hic Et Nunc when viewing it.

After seeing quasimondo’s NFT that displays a list of all the Tezos addresses that collected said artwork I was intrigued. You can access information on an NFT using the API supplied by Better Call Dev, but you cannot know the exact ID of the NFT you are about to mint, nor can you change the content of your NFT after you have minted it.

So how did he accomplish this seeming wizardry? With a smart trick. He edited his NFT by adding the last NFT ID he saw that had been minted, and then when his artwork loads it calls the API up to 20 times, looking for an artwork minted by his Tezos address. As long as less than 20 other NFTs were minted before his it would the ID of itself.

Easy … ? Not really. Genius. Totally!

That said, I was hoping there would be an easier way, or at least a way that didn’t rely on having to call an API multiple times, nor the luck that X number of NFTs hadn’t been minted in the meantime.

So I created this: https://www.hicetnunc.xyz/objkt/17102

It works! At least sometimes. You see NFTs minted by hic et nunc are stored using IPFS (the InterPlanetary File System), a distributed peer-to-peer file system, which can be accessed over the “normal” web using a gateway. The gateway hic et nunc uses is https://cloudflare-ipfs.com/. This routes, and caches, any data requested from IPFS through to the web, and to your browser.

But files you add to IPFS can’t be changed once they have been published. If you change a file, and try to add to IPFS the URL of that file will change. And thus it cannot be loaded from your NFT. But there is a solution that IPFS has for this, called IPNS (InterPlanetary Name System). The idea is it is meant to work somewhat like a DNS lookup, but for IPFS addresses.

How I created an updatable NFT

  • Created an HTML file to contain my final NFT content / code (frame.html)
  • Deployed the frame.html to IPFS
  • Created a new “name” pointing to this IPFS on IPNS
  • I created an HTML NFT which contained nothing but an iframe with a source pointing to the frame.html on IPNS (index.html)
  • Minted my NFT containing index.html. At this point it loaded frame.html from IPNS, but did not contain the minted ID of my new NFT
  • Added the ID of my newly minted NFT to frame.html, deployed it again to IPNS, and pointed my IPNS to this new IPFS url

At this point everything worked. But not very well.

What is bad about this technique?

I’m not an expert at IPFS, nor IPNS. It seems that IPNS is very slow, and from my research this isn’t just a case with using it through the CloudFlare gateway. It is slow to create an IPNS, it takes hours for CloudFlare to show new content from an IPNS, and it seems it can take up to 15 seconds to load the content from an IPNS URL, especially if it hasn’t been accessed recently.

For these reasons I wouldn’t suggest anyone replicates this technique. But if you’re interested here is the basics.

How to use IPNS

  • Install IPFS. I installed both the command line interface (CLI) and the desktop app. If you install the desktop app you can open it to start your daemon (something that runs in the background to handle your IPFS connections).
  • Create a new “key” and give it a name for reference. This is like a “user” on IPFS. Kinda?
    `ipfs key gen — type=rsa — size=2048 MY_ART_REF`
  • Add the current directory to IPFS. The last line printed out after this will include a ‘token’ which is your uploaded directory URL.
    `ipfs add -r ./`
  • Publish the IPFS content to IPNS. This could take a while. Minutes even. With no feedback. Be patient.
    `ipfs name publish — key=MY_ART_REF <the_generated_token_from_ipfs_add>`
  • Note the next ‘token’ that is generated by publishing to IPNS. With this new token you can access your IPNS on CloudFlare like this:
    https://cloudflare-ipfs.com/ipns/<TOKEN>

Note the /ipns/ instead of the normal /ipfs/ in the Cloudfare gateway URL.

Conclusion

I hope this helps someone else create something amazing. But maybe we will just have to wait until IPNS becomes faster.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store