In DAML, what to return when a choice could lead to different new contracts to be created

In DAML, if I have a choice called submit and it could lead to new contract approvedRequest or rejectedRequest. How should I manage the return value in the choice? template Request with content : Text anyone : Party where signatory anyone--what to return ? ApprovedRequest or RejectedRequest controller anyone can Submit : ContractId ApprovedRequest do -- passed all the checks and approved create ApprovedRequest with request = Request...Read more

Daml sandbox persistance ledger id mismatch

When running the quick start tutorial, if you try to persist the data into a Postgres database, you get a ledger identifier mismatch in the console when you restart the sandbox.After checking the database the information for the contracts is still there, but ledger_entries is empty.Steps:daml new quickstart quickstart-javacd quickstartdaml builddaml sandbox dist/quickstart.dar --sql-backend-jdbcurl jdbc:postgresql://localhost/postgres?user=user&password=passThe following is the output on the console:HikariPool-1 - Start completed.HikariPool...Read more

In DAML, how to get ContractId in a choice

In DAML, can I save a contractId of B in contract A? I tried the followings but creating contract returns an update and I cannot save that update anywhere or even access to its data. template OneContract with someParty : Party someText : Text someNumber : Int where signatory somePartytemplate Main with anyone : Party cid : ContractId OneContract where signatory anyone controller anyone can nonconsuming CreateOneContracts : () with p : Party int : Int do-- cid is not bind to ci...Read more

In DAML, how to find and replace an element in a List

If I have a list of data [Item], what is the best way to locate and change an element in it. aList : [Item]searchName : TextnewPrice : Decimal- I can find the element using let a : Optional Int = findIndex (\a -> a.name == searchName) aList-but this doesn't change the value of the Listlet (aList !! fromSome a).price = newPricedata Item = Item with name : Text price : Decimal deriving (Eq, Show)...Read more

daml - Are all parameters required when creating a contract?

When creating a contract from a template, are all the parameters required? What if some fields need to be entered later? template Exp with member1 : Party member2 : Party comment : Text where signatory : member1 choice ABC : () with anotherParty : Party controller member1 do create this with member2 = anotherParty pure()If I want to leave member2 blank when creating the contract, how do I do that? Is it a good pattern or there is better way to work around the problem?...Read more

daml - Storing and retrieving microseconds from DA.Time

I'm working with FIX Timestamp 20180605-03:10:33.0240756 that I need to parse to DA.Time to persist as part of Trade information. I also need to get the microseconds back as part of the response message (ACK/NACK). Ideally I would like to have a simple way of doing it. Currently I'm only storing up to seconds using the DA.Time time constructor. Looking at the https://docs.daml.com/daml/stdlib/base.html#data-prelude-time-24894, seems like the way to retrieve the microseconds is by: creating another time sans microsecondssubTime both to get the R...Read more

How to install the DAML SDK in a Ubuntu VM, which doesn't have the internet connection?

Unable to install the "da-cli-114-7582c1a0bd-linux.run" file in my Ubuntu VM. The setup is failing while checking the latest version check.I have downloaded the latest DAML SDK setup file "da-cli-114-7582c1a0bd-linux.run" and copied the same into my Ubuntu VM through local network connection. When I try to install the .run file, the setup trying to connect to the internet for latest version check. But I am not allowed to use internet in the application servers/VMs. Because of this restriction the setup is getting failed and I am unable to c...Read more

daml - Function for getting today's date?

I am creating a 'choice' inside a contract template that requires checking today's date. My DAML code is as follows:controller dealer can Add_Car : CarId with startCoverage: Date do -- Check for a legal start date assert ( startCoverage > *today* --should check that its not before today ) create this with date_vehicle_added = startCoverageWhat is the name of the function I can use to get the current date? It needs to go where it says "*today*"....Read more

daml - how to get the executed contract id using the Ledger API - Python version

I was trying to get the latest contract id of the exercised command. The CommandService in Ledger API was not returning the latest contract id when the contracts get executed. I could see that the SubmitAndWait is returning the empty as per the below documentation link.https://docs.daml.com/app-dev/ledger-api-introduction/proto-docs.html#commandserviceIs there any other method will help us to get the executed/created contract id?Also, is there any method will help me to pull the contract information based on the contract id?...Read more

How will the DAML Code affecting two distinct DA Nodes be deployed and how will its integrity maintained?

I am looking for DA’s recommendation/best practices regarding writing and deploying DAML code and object (.daml and .dar) in production grade solutions.Let us take a scenario - Central Authority (CA) operating node may issue a new role under a contract to Participant 1 (P1) by writing a simple DAML code, below are few questions related to the DAML deployment – a. Assuming DAML code will be written by CA, can we say that only CA needs to have this code and its build on its node and CA will simply execute the contract workflow allowing Party on ...Read more