Initiate and Accept issue

Trying to create an Initiate and Accept but this is giving an error… Any suggestion where this may have gone wrong. Thanks in advance

import Payment


makePartiesFrom names = mapA getParty names

makeParties = makePartiesFrom []

template ForExTokenMaster
   with
      provider : Party

   where
      signatory provider 
      nonconsuming choice Invite : ContractId ForExIssueProposal
        with client : Party

        controller provider
         do create ForExIssueProposal
             with forExAgreement = ForExIssueAgreement with provider; client
      


template ForExIssueProposal
   with
      forExAgreement : ForExIssueAgreement
   where 
      signatory forExAgreement.provider
      observer  forExAgreement.client
       
      choice AcceptForExTokenProposal 
        : ContractId ForExIssueAgreement
        controller forExAgreement.client
        do create forExAgreement
        

template ForExIssueAgreement
   with
      provider : Party
      client : Party
   where
      signatory provider, client

      nonconsuming choice Issue : ContractId ForExToken 
         controller provider 
         do create ForExToken with ..

template ForExToken
  with
      baseCurrency : Text
      provider : Party --this is the seller of the currency
      client: Party
      description : Text
      networkAdmin : Party -- this is to make sure that the provider and currency buyer are legal
      quote : Text -- this is the currency you will accept in exchange for base currency
      lastRate : Numeric 2 --Decimal -- this is the exchange rate of quote per base curency
      baseCurrencyAmount : Numeric 2 --Decimal -- qty to purchase in quoted currency
      lastExchangeAmount : Numeric 2 --Decimal
      issued :Time -- time the token was launched for sale
      royaltyRate : Numeric 2 --Decimal
      --exchangeAmount : Numeric 2
      delegates : [Party]   
  where
    signatory provider, client 
    observer delegates

What exactly is the error that you are getting?

You need to flll in the other fields when you are creating ForExToken in ForExIssueAgreement:Issue.

One option is to take them as arguments to the Issue choice:

template ForExIssueAgreement
   with
      provider : Party
      client : Party
   where
      signatory provider, client

      nonconsuming choice Issue : ContractId ForExToken
         with
           baseCurrency : Text
           description : Text
           networkAdmin : Party -- this is to make sure that the provider and currency buyer are legal
           quote : Text -- this is the currency you will accept in exchange for base currency
           lastRate : Numeric 2 --Decimal -- this is the exchange rate of quote per base curency
           baseCurrencyAmount : Numeric 2 --Decimal -- qty to purchase in quoted currency
           lastExchangeAmount : Numeric 2 --Decimal
           issued :Time -- time the token was launched for sale
           royaltyRate : Numeric 2 --Decimal
           --exchangeAmount : Numeric 2
           delegates : [Party]
         controller provider
         do create ForExToken with ..

You might want to factor this into a record to make it easier to keep in sync with the fields in ForExToken. See Workflow template factoring with records for some examples of doing that.

1 Like

Thank you for the suggestion!! it now works.

Even without seeing the error, you provide a fix :thinking:

That’s pretty good customer service :+1:t2: :clap:t2: