Do we have a sleep `Update` in Daml?

I mean can we include a waiting step in an Update, like a contract choice?

I know that we have sleep in Daml Script: Module Daml.Script — Daml SDK 2.1.1 documentation

No, there is no waiting primitive. What are you trying to achieve? Updates are transactional, waiting isn’t going to change the state (including the ledger time) so there isn’t anything you can wait for.

1 Like

I want to send a message to the outside world from the ledger in the form of a ledger action (the recommendation is a nonconsuming choice, but for this question this doesn’t matter, could also be the creation of a Message contract), wait some time, and check weather we got the answer in the form of a contract creation, continue if yes, abort if not.

So basically I want to imitate a monadicly composable HTTP call.

I was thinking about faking the sleep in the form of unnecessary lookups, which is of course not reliable in terms of waiting time. Or some computation with big numbers.

This is not going to work. The ledger state observed within an Update does not change over time, you get a consistent ledger snapshot. If the contract didn’t exist at the start of interpretation it’s not going to exist at any point later (unless you create it within the transaction ofc).

If you’re talking to services outside of your Daml ledger you necessarily have to give up on transactionality & use multiple transactions, e.g., first create the message, then wait on the client side until the contract exists and then submit another transaction that uses it.

1 Like

Yes, thanks, this clarifies the situation.