Mint and transfer the NFT#

Now, you are ready to call the mint function. In order to invoke mint function, you need the contract instance and you must set the owner/minter address, the metadata URL, and the token ID. Because you can mint more than one token with this instance address you need to specify the token ID. You can use either your terminal to give these parameters as inputs or you can create a JSON file and give that file as a parameter to concordium-client. To make it more user-friendly, a JSON file is created in this tutorial. In your project file create a folder with any name you want. In this tutorial it is called “nft-artifacts” and the JSON file is called nft-params.json. You can either do it manually or with following commands.

mkdir nft-artifacts
cd nft-artifacts
touch nft-params.json

With a text editor open up that file and place your account address and token ID in the JSON file as shown in the example below.

    "owner": {
        "Account": ["3bzmSxeKVgHR4M7pF347WeehXcu43kypgHqhSfDMs9SvcP5zto"]
    "tokens": ["00000111"]

Minting is successful.


You can also check the dashboard to see the status of your operation in a more visual way. To do that, use the transaction status hash from your terminal.


View function#

Now check the current state of the cis2-nft token contract by invoking view function. The schema file you created in the build step is important here, because concordium-client uses it to deserialize the output while printing it.

concordium-client contract invoke <YOUR-INDEX> --entrypoint view --schema dist/cis2-nft/schema.bin --grpc-port 10001

Your result will be similar to what is shown below where the user is the owner of the token with ID 00000111.


You are going to invoke the tokenMetadata function from your contract. It accepts parameters as a vector. (See the function fn contract_token_metadata()). To give a list of the tokenIDs create another JSON file and call it as token-ids.json and add your tokenID(s) as a vector.

For Mac/Linux/Unix-like operating systems run the following.

touch token-ids.json

Or for Windows run the following.

type nul > token-ids.json

In a text editor, add the tokenID(s) as shown below for the example in this tutorial.


You can query the metadata with the following command.

concordium-client contract invoke <YOUR-INDEX> --entrypoint tokenMetadata --parameter-json nft-artifacts/token-ids.json --schema dist/cis2-nft/schema.bin --grpc-port 10001

This returns the metadata URL combined with your tokenID.


Now the metadata is stored on-chain and no one will be able to change it.

Transfer function#

Now you will transfer the token and check the balance of your account and the other wallet in the following steps.

Before you transfer the NFT, you should change the sender account and receiver account in the ../nft-artifacts/transfer-params.json file. Make sure you make the adjustments of addresses accordingly as shown below. You can create another account on your wallet to transfer this token to that.


Now you can transfer it. One reminder, you should be the owner of it to be able to transfer it, so try not to get confused in this step. The original minter account should be in the from key’s value and the receiver will be located in the to key’s value. When you specify your account addresses and tokenID to be transferred, run the command below. You are going to invoke the transfer function with given parameters.

concordium-client  contract update <YOUR-INDEX> --entrypoint transfer --parameter-json nft-artifacts/transfer-params.json --schema dist/cis2-nft/schema.bin --sender <YOUR-ADDRESS> --energy 6000 --grpc-ip --grpc-port 10001

The transfer is successfully completed.


Check the state of the token once more with the view function.

As you can see the second account is now the owner of the asset and the first account has nothing.


You have now completed part one of the NFT minting tutorial.