I want to get the system date when the daml contract is created. Is there and way to do that.
Example :-
module ExampleTemplateModule where
template ExampleTemplate
with
admin: Party
todayDate: Date --- In place of this can I use getDate and get today's date
where
signatory admin
I know I can do this inside a script-do block, but I want to do it when I have to create a contract. If this is not possible, is there some other way through which I can take system's date while creating daml contracts.
You cannot get the time directly in a create. However, you can get the time in a choice and then create the contract from that. That choice can either be non-consuming and you only create a single helper contract that you call the choice on or it can be consuming and you can call the choice via
createAndExercise. Here is a full example illustrating both options: