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

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

  • 2:

         invokerorgGetClientIdentity().GetMSPID()

  • 3:

         invokerclientGetClientIdentity().GetID()

  • 4:

         testtokentype+_+ownerorg

  • 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:

            idbuyer+_+tokentype

  • 15:

            ownerbuyer

  • 16:

        else

  • 17:

            idinvokerclient+_+tokentype

  • 18:

            ownerinvokerclient

  • 19:

        end if

  • 20:

        tokenReadToken(id)                                          ▹ Calling Algorithm 2

  • 21:

        if token!=nil then

  • 22:

            token.AvailableAssetstoken.AvailableAssets+availableassets

  • 23:

            tokenJSONjson.Marshal(token)

  • 24:

            PutState(id,tokenJSON)

  • 25:

         else

  • 26:

            tokennewNewToken(IDid,TokenTypetokentype, AvailableAssets availableassets,Ownerowner)

  • 27:

            tokenJSONjson.Marshal(tokennew)

  • 28:

            PutState(id,tokenJSON)

  • 29:

            SetTokenStateBasedEndorsement(tokennew.ID,ownerorg,endorserorg)

                                                           ▹ Calling Algorithm 1

  • 30:

        end if

  • 31:

    end function