Skip to main content
. 2021 May 31;21(11):3822. doi: 10.3390/s21113822
Algorithm 3 Create a NFT
  • 1:

    functionCreateNFT(tokentype string, creatingfortransfer bool, buyer string, availableassets int)

  • 2:

         invokerorgGetClientIdentity().GetMSPID()

  • 3:

         invokerclientGetClientIdentity().GetID()

  • 4:

         testtokentype+_+invokerorg

  • 5:

         switch test

  • 6:

                EUnit_Org1MSPorEVUnit_Org1MSP

  • 7:

                endorserorg=Org3MSP

  • 8:

                InUnit_Org2MSPorGaUnit_Org2MSP

  • 9:

                endorserorg=Org1MSP

  • 10:

              StUnit_Org3MSPorEStUnit_Org3MSP

  • 11:

              endorserorg=Org1MSP

  • 12:

        Default: “Invoker Organization and Token Type combination invalid”

  • 13:

        if creatingfortransfer == true then

  • 14:

            idvalbuyer+_+tokentype+_+GetTxID()

  • 15:

            ownerbuyer

  • 16:

        else

  • 17:

            idvalinvokerclient+_+tokentype+_+GetTxID()

  • 18:

            ownerinvokerclient

  • 19:

        end if

  • 20:

        tokennewNewToken(IDidval,TokenTypetokentype, AvailableAssets availableassets,Ownerowner)

  • 21:

        tokenJSONjson.Marshal(tokennew)

  • 22:

        PutState(idval,tokenJSON)

                                                                                                        ▹ Saving new token

  • 23:

        SetTokenStateBasedEndorsement(tokennew.ID,invokerorg,endorserorg)

                                                                                                       ▹ Calling Algorithm 1

  • 24:

    end function