Auto-execute a choice

Hi,

Is it possible to auto-execute a choice based on timing? Can I implement it directly in smart contract or I should implement it as a trigger?

Thank you.

1 Like

Hi @Alex ,

Daml contracts are entirely “passive” — after all, they are records on a ledger. So to answer the first part of your question: no, it is not possible to write a Daml template that auto-executes anything. Actions have to come from the outside. (That’s for the “autoexecute based on timing part”; the choice itself would of course be implemented in the template.)

Daml Triggers have a feature called heartbeat that lets you specify an interval of time on which to call your trigger, so based on your description it seems like that could serve your purposes. If not, please let us know, and maybe we’ll be able to extend the Daml Trigger API to cover more cases.

If the current Daml Trigger API is insufficient (say you need exact times rather than intervals), you can always implement your own application talking to the ledger, using either the JavaScript bindings or the Java bindings, or, if your language preferences take you elsewhere, possibly using no bindings at all — they’re there to make life easier but it is definitely possible to write applications that talk to the Ledger API without them.

2 Likes

thanks @Gary_Verhaegen

1 Like