Skip to main content

Issue CW721 NFT (Vault)

You can use CW721 to easily create NFTs on the XPLA blockchain. Let's give making NFTs a shot by crafting them in your Vault and trying them out in a game!

What is NFT?

NFT stands for Non-Fungible Token, which means it's a token that can't be replaced with something else. But what does Non-Fungible actually mean?

Let's take the example of two $1 bills. They're both worth the same, $1 each, so one can replace the other. Now, think about a drawing of a Mona Lisa that Alice made and the actual Mona Lisa painting in the Louvre Museum. Even if Alice's drawing perfectly depicts every detail of the Mona Lisa, it can't replace the real Mona Lisa painting. This is because they're uniquely different and can't be swapped for each other. This is the idea behind NFTs - they're tokens for things that can't be replaced with something else.

So, what can you do with NFTs? Imagine Alice creates a drawing and wants to use it as her profile picture. But what if someone copies Alice's drawing, claims it as their own, and uses it? What can Alice do? If Alice includes the main information about the drawing in an NFT, she can prove ownership of the drawing. This way, she can establish that she's the real owner of the drawing.

What is CW721?

The XPLA blockchain uses a smart contract platform called Cosmwasm. Similar to Ethereum's ERC721, CW721 is the standard for non-fungible tokens (NFTs) on Cosmwasm. Even though the name might sound similar to ERC721 from Ethereum, they actually work quite differently. If you want to know more details, you can check out the official documentation.

Issue CW721

You can create CW721 contract by following the steps below, and mint NFT!

  1. Access Vault

  2. Create CW721 Contract

  3. Mint NFT

Access Vault

First off, select a wallet for CW20 issuance in your Chrome Extension Vault, then set the network for testnet.

google.com
vaultimgcard
google.com
vaultimgcard

Access the Vault page, and hit Connect on the top right.

https://vault.xpla.io/
vaultimgcard
https://vault.xpla.io/
vaultimgcard
https://vault.xpla.io/
vaultimgcard

Create CW721 Contract

Hit Contract menu on the page.

https://vault.xpla.io/
vaultimgcard

Click on Instantiate.

https://vault.xpla.io/contract
vaultimgcard

Admin here is the owner wallet address of the contract. The wallet address used In the instance below is xpla1cwduqw0z8y66mnfpev2mvrzzzu98tuexepmwrk.

https://vault.xpla.io/contract/instantiate
vaultimgcard

The Code ID for CW contract is 3, so type in 3.

Code ID?

Unlike EVM, the Code Deploy and Contract Creation do not go hand in hand in Cosmwasm. First, when you put your code onto the blockchain (StoreCode), you'll get a special number called a Code ID for that code. Afterward, you can use this Code ID to make a contract (InstantiateContract).

All the contracts made with the same Code ID are based on the same original code. The only difference is that if you provide different starting values (init_msg) when making the contract, the specific details of the contract will be different. For more detailed information, you can take a look at the XPLA Docs.

https://vault.xpla.io/contract/instantiate
vaultimgcard

You need to provide initial values in the Init msg. These values are like the starting settings for your contract, specifically for the NFTs you're going to create. You can see things like who the creator is (minter) and the name of the NFT collection (name).

In the example, we'll input the information in the following format. You just need to put your own wallet address in the minter section. If you want to change the name and symbol values too, you can replace them with different values.

{
"name": "YourNFTName",
"symbol": "YNN",
"minter": "xpla1cwduqw0z8y66mnfpev2mvrzzzu98tuexepmwrk"
}
https://vault.xpla.io/contract/instantiate
vaultimgcard

The Amount refers to the quantity of $XPLA coins you want to send to the contract when performing the Contract Instantiate. Since the CW721 contract doesn't need to hold $XPLA coins, you can actually skip this part.

For the Label, it's a good idea to write something that represents the function of the contract. In the example, we'll use My NFT. Then, go ahead and hit the "Submit" button.

https://vault.xpla.io/contract/instantiate
vaultimgcard

tip

Sometimes, when you're trying to instantiate a contract, you might not be sure what values to put in each field. In such cases, you can look at a contract that has been instantiated with the same Code ID. For instance, let's take a look at another CW721 contract with a Code ID of 3 on XPLA Explorer. By referring to the Init Msg value and adjusting the content to your liking, you can easily create the contract.


When you click the "Submit" button, a popup will appear in the Chrome Extension Vault app. At this point, you'll need to enter your password. This password is used to sign the Instantiate Method transaction. Just type in the password you set up when creating your wallet, and then press the "Post" button.

https://vault.xpla.io/contract/instantiate
vaultimgcard

Once the signing is done, you'll need to wait until the transaction is recorded on the XPLA blockchain. After the transaction is created, you can check its details on XPLA Explorer. Just click on the Tx hash value to see more information.

https://vault.xpla.io/contract/instantiate
vaultimgcard
https://explorer.xpla.io/testnet/tx/4B4656EBDCF401AEBC672C63ABAE5E510234C46EFB395C97764445C3A1B2B130
vaultimgcard

In the EventLogs, you can find the address of the CW721 contract you made.

https://explorer.xpla.io/testnet/tx/4B4656EBDCF401AEBC672C63ABAE5E510234C46EFB395C97764445C3A1B2B130#EventLogs
vaultimgcard

The address of the example CW721 contract is xpla1wx3rm4qxf7l3tczj20mxz62wpnr74kme3f45tvk3muh78c432ucs2ceuqn.


Mint NFT

Now, let's try minting an NFT with the CW721 contract you've created. Go back to the Contract tab on the Vault website.

https://vault.xpla.io/contract
vaultimgcard

In the search field, enter the address of the CW721 contract you made, and then click the "Execute" button.

https://vault.xpla.io/contract
vaultimgcard

In the Msg section, write down the essential information (metadata) for the NFT you want to create. In the example, we'll fill it out like this: For the token_id part, that's the unique number of the NFT. So, every NFT you create in the same CW721 contract should have a different token_id.

In the attributes part, you're describing the characteristics of the NFT. Let's assume we're making a character NFT named Alice with 10 health points (HP) and 100 combat points (CP) for this example.

{
"mint": {
"owner": "xpla1cwduqw0z8y66mnfpev2mvrzzzu98tuexepmwrk",
"token_id": "token_id_myExampleNFT1",
"extension": {
"name": "My Test XPLA NFT",
"attributes": [
{
"value": "Alice",
"trait_type": "CharacterName"
},
{
"value": "100",
"trait_type": "CP"
},
{
"value": "10",
"trait_type": "HP"
}
],
"description": "This is my First NFT in XPLA Blockchain!"
}
}
}
https://vault.xpla.io/contract/xpla1wx3rm4qxf7l3tczj20mxz62wpnr74kme3f45tvk3muh78c432ucs2ceuqn
vaultimgcard
What values should go into the important information (metadata)?

Here are the items that can be included in the important information (metadata):

{
mint: {
owner: "Enter the address of the NFT Owner.",
token_id: "A unique identifier used for individual NFTs, known as Token ID.",
token_uri: "A URI provided in JSON format with the extension information. It follows the same format used by OpenSea.",
extension: {
name : "The name of the NFT.",
description : "A description of the NFT.",
image : "A URL providing the NFT image. It's recommended to keep it around 40MB, with support for up to 100MB.",
animation_url : "A URL providing an animation for the NFT. Recommended size is around 40MB, with support for up to 100MB.",
youtube_url : "A URL for a YouTube video, currently not supported.",
attributes: [ // Represents characteristics of the NFT.
{
category : "NFT item category.",
collection : "NFT Collection.",
creator : "NFT creator or copyright holder.",
provider : "Person with selling or distribution rights for the NFT.",
thumbnail_url : "URL providing a thumbnail image for the NFT.",
extension_url : "URL providing extension information in JSON format for the NFT.",

// Additional NFT characteristics can be added like this.
trait_type: "CharacterName",
value: "Alice",
},
],
},
},
};

If you want more details, you can explore the CW721 GitHub or refer to other NFTs on XPLA Explorer. It's also good to read about the OpenSea Metadata standard.



The next steps are the same as before. Click the "Submit" button and enter your password, and a transaction will be generated.

https://vault.xpla.io/contract/instantiate
vaultimgcard

You can see detailed information about the minted NFT in the XPLA Explorer's Messages tab.

https://explorer.xpla.io/testnet/tx/4B4656EBDCF401AEBC672C63ABAE5E510234C46EFB395C97764445C3A1B2B130
vaultimgcard
https://explorer.xpla.io/testnet/tx/4B4656EBDCF401AEBC672C63ABAE5E510234C46EFB395C97764445C3A1B2B130#Messages
vaultimgcard

That's how you've successfully minted an NFT using the CW721 contract! Remember, NFTs are also tokens, so they're being created through a contract. The key point is that each token has its own unique metadata, which is why you can't swap them out with other tokens created in the same contract. That's a major characteristic of NFTs.