Mint

This section will demonstrate the process of minting and fractionalizing NFTs.

Minting Fractionalized NFTs

In this tutorial, you'll learn how to mint fractionalized NFTs (Non-Fungible Tokens) using the Concordium blockchain. Fractionalizing NFTs involves splitting them into smaller fractions, allowing for shared ownership and trading of digital assets.

Follow the steps below to mint fractionalized NFTs.

Step 1: Mint a CIS-2 NFT

  1. Follow the tutorial to mint a CIS-2 NFT using the cis2-multi smart contract.

  2. Use the mint() function within the cis2-multi contract. The screenshot below shows only the mint() function:

  1. Check the state by calling the view() function with this command:

concordium-client contract invoke <YOUR-TOKEN-CONTRACT-INDEX>--entrypoint view --schema ../cis2-multi/dist/schema.bin --grpc-port 10000 --grpc-ip node.testnet.concordium.com

When you run the command, you should see the following in your terminal:

Step 2: Transfer the NFT to the Fractionalizer Contract

You have successfully minted a CIS-2 NFT, and can now transfer it to the fractionalizer contract. To do that, follow these steps:

  1. Call the transfer() function from the token's contract using its index and schema file.

  2. Create a JSON file with input parameters specifying the token ID, amount, sender, receiver (fractionalizer contract), and any additional data:

[
 {
  "token_id": "<YOUR-TOKEN-ID>",
  "amount": "<TOKEN-AMOUNT-TO-LOCK>",
  "from": {
   "Account": [
    "<YOUR-ACCOUNT>"
   ]
  },
  "to": {
   "Contract": [
    {
     "index": <YOUR-FRACTIONALIZER-CONTRACT-INDEX>,
     "subindex": 0
    },
    "onReceivingCIS2"
   ]
  },
  "data": ""
 }
]

Note the following:

  • You need to use the token’s schema to change its state.

  • Keep both schemas in the same project folder for the sake of organization.

  • You created a section for the cis2-multi contracts schema file, so you can either copy the schema file from cis2-multi to your fractionalizer directory or call it from that file using the JSON provided above.

  • You are creating a file and copying and pasting the schema from cis2-multi.

  1. Run the following command to transfer the token to the fractionalizer:

concordium-client contract update <YOUR-TOKEN-CONTRACT-INSTANCE> --entrypoint transfer --parameter-json cis2-fractionalizer/cis2-multi-transfer.json --schema multi/dist/schema.bin --sender

When you run the command, you will see the following in your terminal:

  1. Check the token contract’s state:

Notice that the fractionalizer contract has one token and your account has the rest.

  1. Check the fractionalizer’s state:

Notice that you have locked the “NFT 01” token as received_token_amount with token_id:01 from the cis2-multi contract.

Step 3: Mint Fractions

Now, you can start minting fractions of it. Use the following steps:

  1. Create a JSON file specifying the owner, token details (ID, amount, metadata), and contract index:

{
 "owner": {
  "Account": ["<YOUR-ACCOUNT>"]
 },
 "tokens": [
  [
   "<YOUR-TOKEN-ID>",
   {
    "metadata": {
     "url": "<METADATA-URL>",
     "hash": "<HASH>"
    },
    "amount": "<FRACTION-AMOUNT>",
    "contract": { "index": <YOUR-TOKEN-CONTRACT-INDEX>, "subindex": 0 },
    "token_id": "<YOUR-TOKEN-ID-COLLATERAL>"
   }
  ]
 ]
}
  1. Mint new tokens based on the collateralized one using the mint() function by specifying the exact token_id and contract index:

concordium-client contract update <YOUR-CONTRACT-INSTANCE> --entrypoint mint --parameter-json ../sample-artifacts/cis2-fractionalizer/mint.json --schema ../cis2-fractionalizer/schema.bin --sender $ACCOUNT --energy 6000 --grpc-port 10000 --grpc-ip node.testnet.concordium.com

When you run the command, you'll see the following in your terminal:

  1. Check the fractionalizer’s state with the following command:

concordium-client contract invoke <YOUR-FRACTIONALIZER-CONTRACT-INDEX> --entrypoint view --schema dist/schema.bin  --grpc-port 10000 --grpc-ip node.testnet.concordium.com

When you run the command, you'll see the following:

Note: New fraction’s are CIS-2 tokens, you can transfer them or sell them on a marketplace. Any functionality applicable to a CIS-2 token extends to these fractions as well.

You've now locked an NFT and created 1000 fractions that represent the token.

Last updated