Developing XDroids - a generative NFT project

Developing XDroids - a generative NFT project


Our job was to develop an NFT contract from scratch. A client had a unique project to do, one that not many can offer a solution to.

The potential of NFTs

A non-fungible token (NFT) is a non-interchangeable unit of data stored on a blockchain, that can be traded on collectible markets like Open Sea. These tokens are non-fungible because they are not equivalent to each other.

Typically, people believe that an NFT is simply an image on the blockchain and by that definition we could agree that the potential is limited. However, it's much more than that. We can add metadata to them, describing any amount of attributes we deem necessary.

Every week, artists and developers take note of the flexibility of these tokens and create art to consequently introduce attributes to them. For example, we can describe a Pokemon’s image with a set of attributes including type, height, name, powers, etc. This information has tremendous potential for gaming.

Take a look at the CryptoKittes project, where each kitten is “bred” and is given a random image and genotype describing their physical traits. Some genes are rarer than others, making them more expensive and sought after. The final image is an unerring illustration of the genotype metadata.

Once the images are uploaded to the blockchain, we can associate them with their corresponding properties. These projects are indexed by Open Sea and can be traded between crypto owners. Projects can reach billions of dollars in total market capitalization.

In this case, our client wanted a collection of “androids” or “droids”. These figures would be represented by a PNG file for the art, and a JSON file containing image descriptions.

As you can see, the droid is defined by the following properties.

  • Name
  • Description
  • Image
  • DNA
  • Edition
  • Date created
  • Attributes
  • Trait type
  • Value

In the attributes section, our example droid would have a “matrix background” as a descriptor. The sword on its back would be defined as “purple sword” in the same section. A complete metadata example can be found here.

What is a Smart Contract?

A smart contract is a computer program that executes a set of instructions on Ethereum which mostly include handling cryptocurrency without intermediaries. The lines of code of these contracts can be viewed by anyone using Blockchain indexers such as Etherscan, thus making it safe for users to use.

ERC721 Token

Our client needed a smart contract to “mint” (or fabricate) the Droid NFTs, so we began the development by creating an ERC721 token, which is the formal definition of a non-fungible token. This token is provided by OpenZeppelin – an organization that researches and develops new standards for blockchain code, all of which are widely adopted.

An ERC721 token consists of various methods that are supplied to the buyers, owners, and blockchain indexers. The _safeMint function allows us to fabricate a new NFT with an automatically incremented Token ID that is used as the NFT identifier. There is also a function that permits us to generate the Token URI (tokenURI). This one is often used by the markets to display a collection’s art. For this purpose, we uploaded all the images and JSON data to an IPFS server that shall host all of the project’s data.

The complete smart contract code can be found here.

Minting Dapp

Users need a user-friendly website to incentivize them to create their own droids. The other option is to offer them the Etherscan link, where you can execute the minting commands directly, but this is not ideal as most people do not know how smart contracts work.

Things we learned

  • Ethereum is expensive – Building a project on the Ethereum network can require thousands of dollars, which makes learning the intricacies of the technology quite difficult. As reference, costs of deployment to the Ethereum mainnet can cost over thousand dollars. This is only a portion of the total possible expenses. The whitelist method, which is one of the functionalities that we added to the smart contract, cost us ten thousand dollars to execute.
  • Ethereum is slow – Deployment to the mainnet can take from one hour to three hours.
  • Byte Size is important – One must pay attention to the amount of lines they’re adding to the smart contract, because if it totals 24.5kb or more, it will not deploy. To mitigate the size, it is necessary to use Solidity libraries and proxy contracts. This is important to reduce deployment costs. There exists a standard to componentize the logic of a Solidity project and it is called Diamond Storage.

Public Reception

The project went public on the 31st of January and over a hundred mints were made in just 12 hours, totalling thirty thousand in sales and still growing. The funds received will be used to develop a Play to Earn videogame in the upcoming months.

Recent Articles