Tools for automated NFT minting

github twitter github

Some time ago, I wrote an article about NFT minting on the Elrond blockchain. I also built elven.tools app. It is a prototype and first iteration of an app that I would like to have in the future. I want to continue the NFT topic and present to you my two handy tools. So this will be rather a demo than a tutorial, but I think still worth reading. The tools are open-sourced. You'll be able to read more about the future of elven.tools too. But first, a couple of words of introduction.

What is the purpose of that?

First of all, I write articles and build tools for learning purposes. If you want to learn new stuff, my advice is to find an idea for a project and start writing the code. Start figuring out stuff while digging deeper and deeper. And this is what I do with the Elrond blockchain. But I also like the idea of the NFT concept, maybe not as an art collecting, but as a unique kind of ID and perhaps a key to the world of many different communities or so-called metaverses, which started to appear very recently. I also like to think about them as our future 'skin' in the world of peer-to-peer networking, and I can see the NFTs as a vital part of that trend.

Disclaimer

As always, please be careful when using my tools and knowledge, it isn't perfect in many ways, but I hope it will be helpful in a couple of cases. It also improves in time. If you read something, please validate it. If you use my open-source tools, also validate and review the code.

The state of the elven.tools app

Elven.tools can mint NFTs using Elrond's JavaScript SDK. But it doesn't use custom and dedicated smart contract (yet!). You can mint an NFT on the devnet, they are transferred to you, and you can list them there. That's it, and there are no marketplace-like features. These features are planned, and I even created a simple roadmap for them.

I have a custom smart contract for it already, but it needs a lot of improvements, and it isn't ready for integration. I will work on that soon. The first iteration of enhancements will be to integrate a smart contract that will mint a single NFT, list it, and transfer the token to the author. Maybe with some unique functionalities, to be a little bit different than many similar apps. But as I wrote already, the primary purpose is to learn and share, not to have a side project, which would be awesome, by the way.

Then in the future, I would like to have a small marketplace there, and I would like to have tools that allow releasing whole collections there.

How to do that? I am not sure at 100% yet. But I have a rough idea. And I started work on the tools which can help. Let's see what it is.

First tool   >>>   nft-art-maker

The main idea behind this tool is to generate extensive random collections of NFT images based on image layers. So, for example, we could have something similar to the Crypo Punks. Every Crypto Punk results from randomized combinations of layers, like face, hair, eyes, etc.

The tool allows to generate standard .png files, but it also allows SVG files encoded with base64. Every file will be hashed using sha256, and the order in the output JSON file will also be hashed using a provenance hash - hash of all image hashes in the order of generation. You can publish provenance hash before minting tokens and connecting them with images stored, for example, using the IPFS CAR to prove that no one didn't manipulate it in any way before that process.

The tool is based on a couple of other libraries, like HashLips Art Engine (only main functionality), SVGO and Pixels to SVG. The last two are used for SVG generation. The idea with SVG was to keep the art pieces on-chain. Which, in many cases, isn't a good idea, but I believe that it comes with added value. You have all of the data on-chain, including your art piece, and you don't have to depend on third-party services which will host the image. Even if we speak about decentralized solutions like IPFS, if we have tiny images, it could be worth the additional cost we must pay when creating those.

To sum up, the tool will output a metadata.json file and ready-to-use images or encoded SVGs placed in the metadata.json file. In the case of standard png images, there is an option to generate a metadata file for each image and pack them using ipfs-car. This way, you'll get unique CIDs for every file that you can then upload using nft.storage or similar services. All CIDs will be already placed inside the metadata JSON files.

SVGs, on the other hand, are encoded to be used as valid URIs. So you can grab it and paste it into the browser's address, and it should display an SVG file.

You can download the image and use some online tooling to get the sha256 hash in both cases. Then, you can compare it with what is put in the attributes of the NFT on the blockchain.

Please check out three short walkthrough videos on how it works:

You probably wonder, ok, and how to use such data to mint real NFTs on the Elrond Blockchain. Here we can jump to the second tool.

Second tool   >>>   elven-mint

The tool is the early version of an automated NFT minter on the Elrond blockchain. It uses the output files from the previous tool and erdjs SDK.

Its primary function is to iterate the metadata.json editions collection and mint tokens.

It assumes that the person who wants to mint the collection already has a smart contract that exposes the 'create nft' function that implements esdt_nft_create.

It also assumes that you already have an ESDT token with proper roles, and the token can be used as the base for the collection. Read more here.

All is configured using the configuration file. You'll find more info about it in the repository.

The tool uses a Keystore wallet file and password, and it will ask for a password when used. It is required to run it in the directory with metadata.json, wallet.json, and .elvenmintrc config. You can define the names of these files if needed. Again, see the readme in the repo for more information on how to configure it.

You can also watch the quick walkthrough video:

Ok, but how do these relate to elven.tools?

Although these are separate tools that you can use in many different cases, the plan is to use them as testing tools of the smart contract at the first stage of development. But I also see them as additional tools which could be incorporated as part of the elven.tools code in the future. If not directly, maybe as core tools around it.

The main goal is the collections and automated minting. It isn't a trivial feature because it should also be secure, and the author should mint the whole collection because of royalties, etc. Of course, using a browser-based app is not a good idea in such cases unless we can use the Keystore file to sing all transactions we will define. The second option is to do this on the server, but I am unsure if this won't produce any problems. I need to do more research on that.

Most likely, the best option would be to get the royalties cut for every NFT on the smart contract level, take the cut and send it back to the author. It will probably work like that. But I'll see.

Summary

I decided to go back to developing elven.tools because I can learn a lot in this process. I also like the NFT hype, and I like that this hype brings a lot of new people closer to the technology on which it all is built, and I am sure that it will evolve and be much bigger than only expensive collectible images.

I will focus more on learning elrond-wasm-rs and on improving the smart contract. I hope I will be able to deploy a simple version soon. Till then, please leave all possible feedback regarding these two tools. I haven't minted any real NFT collection yet, so I may lack some knowledge of how it should look. For now, I am focused on the technical side of it, so your feedback will be very appreciated.

Catch me on Twitter and GitHub.