# setTime for Scripts works after all?

**URL:** <https://forum.canton.network/t/settime-for-scripts-works-after-all/2101>\
**Category:** App Development\
**Tags:** daml-sdk\
**Created:** [February 16, 2021, 9:08pm UTC](https://forum.canton.network/t/settime-for-scripts-works-after-all/2101 "2021-02-16T21:08:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Bernauer](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/alexander_bernauer/32/1703_2.png) [@Alexander\_Bernauer](https://forum.canton.network/u/Alexander_Bernauer)\
**Post date:** [February 16, 2021, 9:08pm UTC](https://forum.canton.network/t/settime-for-scripts-works-after-all/2101/1 "2021-02-16T21:08:51Z")

</div>

Hi,

the [documentation for setTime](https://docs.daml.com/daml-script/api/Daml-Script.html#function-daml-script-settime-36710) states

```
This is only supported in static time mode when running over the gRPC API and in Daml Studio.

```

Also, the [documentation for Script](https://docs.daml.com/daml-script/index.html) states

```
setTime is not supported and will throw a runtime error

```

But I have a Script here that uses `setTime`, and when I run `daml test` this seems to work just fine. The test output is reporting a ledger time that is equal to what I have configured via `setTime`.

Can anyone provide an explanation that resolves this apparent contradiction?

Regards,  
Alex

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [February 16, 2021, 9:12pm UTC](https://forum.canton.network/t/settime-for-scripts-works-after-all/2101/2 "2021-02-16T21:12:00Z")

</div>

`daml test` runs against a special dummy in-memory ledger (what we used to call the scenario service but that name is a bit silly now that it runs daml scripts) which is always in static time mode. This is the same in memory ledger also used by Daml Studio so the same thing applies there. If you run it against a real ledger over gRPC (`daml test-script` works for this as well although it looks like it might still default to static time mode), you will get an error if your ledger is not configured in static time mode which for Sandbox means you haven’t passed `--static-time`.

---

<div class="post-metadata">

**Author:** ![anthony](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/anthony/32/419_2.png) [@anthony](https://forum.canton.network/u/anthony)\
**Post date:** [February 16, 2021, 9:18pm UTC](https://forum.canton.network/t/settime-for-scripts-works-after-all/2101/3 "2021-02-16T21:18:59Z")

</div>

~~Should the line in the Script docs be `setTime is only supported in static time mode and will throw a runtime error if it's not` then?~~

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [February 16, 2021, 9:20pm UTC](https://forum.canton.network/t/settime-for-scripts-works-after-all/2101/4 "2021-02-16T21:20:24Z")

</div>

The line you’re quoting is in the section on running Daml Script over the JSON API. There it is never supported.

---

<div class="post-metadata">

**Author:** ![Alexander\_Bernauer](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/alexander_bernauer/32/1703_2.png) [@Alexander\_Bernauer](https://forum.canton.network/u/Alexander_Bernauer)\
**Post date:** [February 17, 2021, 7:54am UTC](https://forum.canton.network/t/settime-for-scripts-works-after-all/2101/5 "2021-02-17T07:54:51Z")

</div>

I think what could be useful is a table that is providing an overview of all the options to run DAML code, scenarios and scripts, the specific features and constraints for each (static time, JSON API, contract IDs, etc.) , the general steps how to do that (DAML Studio, daml start, daml test, daml sandbox, deploy to Sandbox, deploy to DABL, deploy to other ledger, etc), and how those options relate to each other.

Maybe this is something for your cheat sheet, @drak?

Regards,  
Alex

---

<div class="post-metadata">

**Author:** ![drsk](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/drsk/32/43_2.png) [@drsk](https://forum.canton.network/u/drsk)\
**Post date:** [February 22, 2021, 1:19pm UTC](https://forum.canton.network/t/settime-for-scripts-works-after-all/2101/6 "2021-02-22T13:19:31Z")

</div>

Thanks for the fresh ideas! I’ll update the cheat sheet soon.
