How to mint an NFT

There are several ways to mint NFTs on Chiliz Chain, depending on your needs. This page aims to present the most recommended ways.

Prerequisites

Three things are necessary for you to mint NFTs:

  1. A Web3 wallet: To interact with Chiliz Chain (Chiliz Mainnet or Spicy Testnet), you need a Web3 wallet address with some amount of CHZ on it. CHZ is the native Chiliz Chain token.

  2. An deployed NFT smart contract: Before a file can be minted into an NFT, you must deploy and verify a corresponding NFT smart contract on Chiliz Chain. This is a crucial step to ensure transparency and enable interaction with your contract on-chain.

  3. A online location for your NFT files & metadata: One essential part of your NFT is to have it available online, for all to see. One way to do that it to have your media file (image/video/etc.) and its metadata.json file accessible via IPFS.

See the sections below to learn more about each aspect.

Getting your own Web3 wallet

A Web3 wallet serves as both storage for your CHZ tokens, and as your digital signature to approve on-chain actions.

You can use MetaMask or any other Web3 wallet:

How to use MetaMask

Once installed, set your wallet up to work with Chiliz Chain:

Connect to Mainnet and Testnet

Make sure to obtain CHZ tokens in order to pay for gas fees on Chiliz Chain Mainnet. You can buy CHZ on any exchange such as Binance, Coinbase, Bitpanda, etc.

To test your ability to mint NFTs on Chiliz Chain, you should use the Spicy Testnet with test CHZ tokens. You can obtain free tokens through testnet faucets:

Testnet Faucets

Deploying and Verifying your NFT Smart Contract

You can deploy your smart contract to Chiliz Chain using reputable platforms, such as Remix IDE or thirdweb.

The most secure and common way to obtain a NFT-minting contract is by using the one from OpenZeppelin, for instance their ERC-721 contract. This saves you from reinventing the wheel and helps prevent common security vulnerabilities.

Once you have deployed it, you must verify the contract on an block explorer, so that developer tools and platforms can read its ABI (Application Binary Interface) and interact with it.

Follow these guides to deploy then verify your NFT contract:

Deploy and verify a contract

Again, pay attention to use the correct network details for Chiliz Chain and Spicy Testnet:

Connect to Mainnet and Testnet

Handling media files with IPFS

If you don't know it yet, having an NFT does not mean have your media file is not uploaded as-is on the blockchain. Rather, an NFT corresponds to a blockchain block that contains a token. This token stores a pointer called tokenURI which links to a metadata file, which itself references the media file using another URI.

Because of the peer-to-peer nature of the blockchain, you cannot just host your media files and their metadata files on any web hosting service. Your tokenURI needs to stay permanent (or "immutable") and portable across apps and marketplaces, for as long as can be, possibly forever.

The IPFS website has an extensive page on NFT Storing best practices.

When uploading your NFT, you need to perform two uploads to the Content Identifier (CID) that IPFS generates for you:

  • The content itself, for which IPFS returns an IPFS URL for the hosted file.

  • The metadata file, which references the CID of the media file, and must contain the IPFS URL for the file.

Both are to be uploaded on IPFS under the same CID. Ideally, your toolset takes this in charge so that you don't have to do it all manually.

For information purpose, here is what a minimal metadata.json file would look like:

{ 
    "name": "Stadium Pass #25456456", 
    "description": "PSG supporter entry ticket", 
    "image": "ipfs:///filename.png",           // for static images only!
    // "animation_url": "ipfs:///filename.mp4" // for video and audio files.
    "attributes": [
    { 
        "trait_type": "Tier", 
        "value": "Gold" 
    }] 
}

To learn more about NFT metadata structure (for instance, why you should use image for images and animation_url for videos), we advise you to read this document from OpenSea:

Note: You are not supposed to write the metadata file from scratch! Your toolset should be able to generate it for you.

As this documentation is not meant to describe everything about IPFS, we advise you to dive into the topic through online searches. You can start with this Pinata explainer:

... or this blogpost from thirdweb:

Choose your toolset

Minting with viemMinting with thirdwebMinting with Rarible

Last updated

Was this helpful?