Creating Move NFT
Overview
Creating and managing your own NFTs using the 0x1::simple_nft
module involves several steps, including creating a collection, minting NFTs, checking minted NFTs, and transferring NFTs. This tutorial will guide you through these steps, focusing on syntax and essential commands to interact with the blockchain.
Tutorial
Step 1: Create Collection
To mint NFTs, you first need to create a collection. You'll use the 0x1::simple_nft::create_collection
function for this purpose. This function requires numerous parameters, including descriptions, maximum supply, collection name, and various flags to allow mutability in your collection's properties.
public entry fun create_collection(
creator: &signer,
description: String,
max_supply: Option<u64>,
name: String,
uri: String,
mutable_description: bool,
mutable_royalty: bool,
mutable_uri: bool,
mutable_nft_description: bool,
mutable_nft_properties: bool,
mutable_nft_uri: bool,
royalty: Decimal128,
)
> initiad tx move execute 0x1 simple_nft create_collection \
--args "string:description option<u64>:100 string:my_collection string: bool:true bool:true bool:true bool:true bool:true bool:true decimal128:0.05" \
--from [key-name] \
--gas auto --gas-adjustment 1.5 --gas-prices 0.15uinit \
--node [rpc-url]:[rpc-port] --chain-id [chain-id]
Step 2: Mint NFT
After creating a collection, you can mint NFTs within this collection using the 0x1::simple_nft::mint
function. This function also requires various parameters, including the collection name, a description of the NFT, the token ID, and an optional recipient address.
public entry fun mint(
creator: &signer,
collection: String,
description: String,
token_id: String,
uri: String,
property_keys: vector<String>,
property_types: vector<String>,
property_values: vector<vector<u8>>,
to: Option<address>,
)
> initiad tx move execute 0x1 simple_nft mint \
--args "string:my_collection string:nft_description string:nft_1 string: vector<string>: vector<string>: vector<vector<u8>>: option<address>:[receiver-addr]" \
--from [key-name] \
--gas auto --gas-adjustment 1.5 --gas-prices 0.15uinit \
--node [rpc-url]:[rpc-port] --chain-id [chain-id]
Step 3: Check Minted NFTs
You can check the NFTs you've minted by accessing specific APIs. For checking collections and tokens owned by a specific address, use the following endpoints, replacing [addr]
and [collection_address]
with actual values:
Collections owned by a specific address: https://api.initiation-1.initia.xyz/indexer/nft/v1/collections/by_account/[addr]
NFTs owned by a specific address: https://api.initiation-1.initia.xyz/indexer/nft/v1/tokens/by_account/[addr]
Step 4: Transfer NFT
To transfer an NFT, use the 0x1::object::transfer_call
function. This function allows transferring a single NFT from one account to another.
public entry fun transfer_call(
owner: &signer,
object: address,
to: address,
)
> initiad tx move execute 0x1 object transfer_call \
--args "address:[object-addr] address:[receiver-addr]" \
--from [key-name] \
--gas auto --gas-adjustment 1.5 --gas-prices 0.15uinit \
--node [rpc-url]:[rpc-port] --chain-id [chain-id]
Last updated