Initia (Closed Testnet)
  • Reminder
    • ⛔Confidentiality Disclaimer
  • WELCOME TO CLOSED TESTNET
    • Welcome to Closed Testnet
  • About Initia
    • What is the Initia Platform?
      • Architecture
        • Layer 1
        • Layer 2
      • Aligning Initia (coming soon!)
    • InitiaDEX
    • Enshrined Liquidity and Staking
  • Developers
    • Initiad
      • Download Initiad
      • Using Initiad
    • Get INIT token
    • Build your own Minitia
      • Simple Minitia Setup
      • Connect Minitia to L1
        • OPinit Stack
          • OPinit Module
          • OPinit Bots
        • Relayer
          • Fetching Oracle Prices
    • Virtual Machines
      • MoveVM
        • Interact with CLI
      • WasmVM
    • Contracts
      • Move Contracts
      • CosmWasm Contracts
      • EVM Contracts (Coming Soon)
    • Oracles
  • Initia Developer Tutorials
    • 1. Create account
    • 2. Send Move coin
    • 3. Interchain Message
    • 4. Create your own Move coin
    • 5. Create your own Move NFT
    • 6. Build and Publish Contracts
      • Move Module
      • CosmWasm Contract
  • Core Applications
    • Core Applications
      • Wallet
      • Initia App
      • Usernames
      • Initia Scan
  • Node Operators
    • Running Initia Node
      • Prerequisites
      • Oracle
      • Boot an Initia Node
      • Connect to Initia Network
      • Cosmovisor Guide
    • Configuring Initia Validator
  • References and Tools
    • Move Language
    • Rust Language (CosmWasm)
    • Closed Testnet Chain Information
    • Chain Parameters
    • Initia.js
    • API Docs
    • API Docs (minimove)
    • API Docs (miniwasm)
    • Whitelisted Tokens and Pairs
Powered by GitBook
On this page
  • Step 1: Create Collection
  • Step 2: Mint NFT
  • Check minted NFTs
  • Transfer NFT
  1. Initia Developer Tutorials

5. Create your own Move NFT

This tutorial covers a guide to mint my own NFT and collection using 0x1::simple_nft module. Also, let's understand the concept of Object by transfering NFTs.

Previous4. Create your own Move coinNext6. Build and Publish Contracts

Last updated 1 year ago

Step 1: Create Collection

To create NFTs, a collection must be created first. Let's use to create a new collection.

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]
import {
  bcs,
  LCDClient,
  MnemonicKey,
  MsgExecute,
  Wallet,
} from '@initia/initia.js';

async function createCollection() {
  const lcd = new LCDClient('[rest-url]', {
    gasPrices: '0.15uinit',
    gasAdjustment: '1.5',
  });

  const key = new MnemonicKey({
    mnemonic: 'beauty sniff protect ...',
  });
  const wallet = new Wallet(lcd, key);

  const msgs = [
    new MsgExecute(
      key.accAddress,
      '0x1',
      'simple_nft',
      'create_collection',
      [],
      [
        bcs.string().serialize('description').toBase64(), // collection description
        bcs.option(bcs.u64()).serialize(100).toBase64(), // max supply
        bcs.string().serialize('my_collection').toBase64(), // collection name
        bcs.string().serialize('').toBase64(), // collection uri
        bcs.bool().serialize(true).toBase64(), // mutable collection description
        bcs.bool().serialize(true).toBase64(), // mutable collection royalty
        bcs.bool().serialize(true).toBase64(), // mutable collection uri
        bcs.bool().serialize(true).toBase64(), // mutable nft description
        bcs.bool().serialize(true).toBase64(), // mutable nft properties
        bcs.bool().serialize(true).toBase64(), // mutable nft uri
        bcs.decimal128().serialize('0.05').toBase64(), // royalty
      ]
    ),
  ];

  // sign tx
  const signedTx = await wallet.createAndSignTx({ msgs });
  // send(broadcast) tx
  lcd.tx.broadcastSync(signedTx).then(res => console.log(res));
  // {
  //   height: 0,
  //   txhash: '0F2B255EE75FBA407267BB57A6FF3E3349522DA6DBB31C0356DB588CC3933F37',
  //   raw_log: '[]'
  // }
}

createCollection();

Step 2: Mint NFT

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]
import {
  bcs,
  LCDClient,
  MnemonicKey,
  MsgExecute,
  Wallet,
} from '@initia/initia.js';

async function mintNft() {
  const lcd = new LCDClient('[rest-url]', {
    gasPrices: '0.15uinit',
    gasAdjustment: '1.5',
  });

  const key = new MnemonicKey({
    mnemonic: 'beauty sniff protect ...',
  });
  const wallet = new Wallet(lcd, key);

  const msgs = [
    new MsgExecute(
      key.accAddress,
      '0x1',
      'simple_nft',
      'mint',
      [],
      [
        bcs.string().serialize('my_collection').toBase64(), // collection name
        bcs.string().serialize('nft_description').toBase64(), // nft description
        bcs.string().serialize('nft_1').toBase64(), // nft token id
        bcs.string().serialize('').toBase64(), // nft uri
        bcs.vector(bcs.string()).serialize([]).toBase64(), // property keys
        bcs.vector(bcs.string()).serialize([]).toBase64(), // property types
        bcs.vector(bcs.vector(bcs.u8())).serialize([]).toBase64(), // property values
        bcs.option(bcs.address()).serialize(key.accAddress).toBase64(), // to, if null mint to creator
      ]
    ),
  ];

  // sign tx
  const signedTx = await wallet.createAndSignTx({ msgs });
  // send(broadcast) tx
  lcd.tx.broadcastSync(signedTx).then(res => console.log(res));
  // {
  //   height: 0,
  //   txhash: '162AA29DE237BD060EFEFFA862DBD07ECD1C562EBFDD965AD6C34DF856B53DC2',
  //   raw_log: '[]'
  // }
}

mintNft();

Check minted NFTs

There are multiple ways to check NFTs, but the below API can be used to check the NFTs minted to myself.

Transfer NFT

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]
import {
  bcs,
  LCDClient,
  MnemonicKey,
  MsgExecute,
  Wallet,
} from '@initia/initia.js';

async function transferNft() {
  const lcd = new LCDClient('[rest-url]', {
    gasPrices: '0.15uinit',
    gasAdjustment: '1.5',
  });

  const key = new MnemonicKey({
    mnemonic: 'beauty sniff protect ...',
  });
  const wallet = new Wallet(lcd, key);
  const msgs = [
    new MsgExecute(
      key.accAddress,
      '0x1',
      'object',
      'transfer_call',
      [],
      [
        bcs
          .address()
          .serialize(
            '0x6bb8659546a0c220a6f47f97042b79262afeecc87b59b9db1d60869fafe965b3'
          )
          .toBase64(), // object address (nft address)
        bcs
          .address()
          .serialize('init10v3kg8hfvsj6tklfj5aam9ya5lmvtl9snqsawg')
          .toBase64(), // receiver address
      ]
    ),
  ];

  // sign tx
  const signedTx = await wallet.createAndSignTx({ msgs });
  // send(broadcast) tx
  lcd.tx.broadcastSync(signedTx).then(res => console.log(res));
  // {
  //   height: 0,
  //   txhash: '6C34E97A9AECFC89765AC63225EB731BCED34C5B05281B17A4D28B8730CCFC55',
  //   raw_log: '[]'
  // }
}

transferNft();

Call function to mint NFTs to myself.

Get collection list owned by me: [addr]

Get NFT list owned by me: {collection_address}

A single NFT is a single object, and transfer can be done by .

0x1::simple_nft::create_collection
0x1::simple_nft::mint
https://stone-api.initia.tech/v1/nfts/collections?account=
https://stone-api.initia.tech/v1/nfts/tokens?account={my_address}&collection=
0x1::object::transfer_call