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.
What is an NFT?
As per Wikipedia, "A non-fungible token (NFT) is a unique digital identifier that is recorded on a blockchain and is used to certify ownership and authenticity. It cannot be copied, substituted, or subdivided. The ownership of an NFT is recorded in the blockchain and can be transferred by the owner, allowing NFTs to be sold and traded."
In effect, an NFT is made of:
a media file (image, video) available online,
its attached metadata file, which notably features the web address where the media file is stored,
a blockchain's block, which stores the metadata file along with an NFT-centric smart contract that offers methods to interact with the NFT.
NFTs on Chiliz Chain follow the EVM standards (for instance: ERC721, ERC-1155, etc.), which ensure interoperability across tools and marketplaces.
What is NFT minting?
NFT minting is the process of taking a digital file (such as an image, a video, or a piece of music) and turning it into an on-chain token: a verifiable digital asset that can be owned and transferred.
Prerequisites
Three things are necessary for you to mint NFTs:
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.
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.
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.
Which smart contract to use?
There are many smart contracts in the blockchain world, and it might not be obvious which one is suitable for NFT minting.
Which smart contract you need depends on what kind of NFT project you have in mind:
One unique item: Use an ERC-721 NFT contract, and mint a single item with it.
Many unique item: Use an ERC-721 NFT contract, ans mint a collection of items with it.
Several copies of the same item: Use an ERC-1155 Multi Token contract (allows one item to have more than one instance).
Several copies of several items: Use an ERC-1155 Multi Token contract as well.
There are others smart contracts (known as contract extensions or variants) for different usages (such as ERC-2981 for Royalties, ERC-4906 for Metadata update event, ERC-721 Drop for lazy-minting, etc.), but for now, knowing about ERC-721/1155 is enough.
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 MetaMaskOnce installed, set your wallet up to work with Chiliz Chain:
Connect to Mainnet and TestnetMake 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 FaucetsDeploying and Verifying your NFT Smart Contract
You can deploy your smart contract to Chiliz Chain using reputable platforms, such as Remix IDE or thirdweb.
Should I write my own smart contract?
Even if you want to have full control on your code, we DO NOT recommend writing ERC‑721 contracts from scratch. You should use the battle‑tested and audited contracts from reputable contract libraries.
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.
OpenZeppelin is an open-source platform for building secure dApps.
In addition to several security and auditing services, they provide a library of community-vetted smart contracts, free for anyone to use in their projects.
As such, OpenZeppelin contracts are considered industry standards, and you can safely rely on them.
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 contractMake sure to verify your contract on one of the Chiliz Chain block explorers!
Only verified contracts can mint NFTs that are compatible with Socios.com and the Socios.com Wallet.
Again, pay attention to use the correct network details for Chiliz Chain and Spicy Testnet:
Connect to Mainnet and TestnetHandling 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.
About IPFS
IPFS, for InterPlanetary File System, is a decentralised file network which servers the purpose of hosting and sharing data across distributed networks. NFT platforms can fetch data from IPFS instead of relying on a single server, and the IPFS protocol makes it "feel" like all hosted files are local.
Do I need to learn about IPFS right now?
It depends on your chosen method to mint your NFT:
Through a dashboard such as thirdweb: No. Uploading to IPFS is built in. You can still paste an existing
ipfs://...
if you have one in the NFT parameters.Using most Web3 SDKs (such as Rarible's Multichain SDK): Yes, they will expect a URI. Some tools might help with uploads, but not most.
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.
You can either run your own IPFS node, or pay for an IPFS-host, such as Pinata, which offers a free pricing plan that might be enough for your needs.
Follow Pinata's quick-start guide in order to obtain your API credentials (consisting of an API key, an API secret, and a JWT token) and your Dedicated Gateway domain (for instance, blue-genetic-quail-122.mypinata.cloud
).
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 RaribleLast updated
Was this helpful?