Developing XDroids - a generative NFT project

Developing XDroids - a generative NFT project

What is an NFT?

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.

XDroids NFT

In this case, our client wanted a collection of randomly generated androids. These figures are represented by a PNG file for the art and a JSON file for the metadata.

Example NFT on OpenSea (NFT Marketplace)
  "name": "XDROIDS #147",
  "description": "XDroids is a collection of 10,000 unique hand-drawn NFT's living on the Ethereum blockchain",
  "image": "ipfs://QmZFM9wyPATcbacsUQAXpbSxvaDUV11TYvHU3VTQNMdyC7/147.png",
  "dna": "c1dbc284cbbb724feb761672e5ab79c3ef2fc475",
  "edition": 147,
  "date": 1643395444370,
  "attributes": [
Example NFT metadata

As you can see, the android is defined by certain properties in the JSON metadata file. Generally, these archives are automatically generated by the HashLips Art Engine.

In the attributes section, our example android has a “matrix background” as a descriptor. The sword on its back is defined as “purple sword”. A complete metadata example can be found here.

      "trait_type": "Rare Backgrounds",
      "value": "Background_matrix_green"
      "trait_type": "Rare Back Accessories",
      "value": "Sword_purple"

On Open Sea (the Ethereum NFT market) we can find the complete data shown in a neat UI.

XDroid Properties
xDroid Price history, listings, and offers

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 is a token standard defined by OpenZeppelin – an organization that researches an d 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 XDroids 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. 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, would have cost us ten thousand dollars to execute. Instead, we decided to implement this feature through the frontend, and not in the smart contract itself.
  • Ethereum is slow – Deployment to the mainnet can take from one hour to three hours.
  • Byte Size is important – We must pay attention to the amount of lines we are 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 is 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.