pactpact-lang

How to get current time in Pact / Kadena


How do you get the current time in pact? I couldn't find it in the documentation

https://pact-language.readthedocs.io/en/stable/pact-functions.html?highlight=time#time-2


Solution

  • Found the answer -

    It can be found under the block-time variable under chain-data documentation

    Example:

    pact> (chain-data)
    {"block-height": 0,"block-time": "1970-01-01T00:00:00Z",
    "chain-id": "","gas-limit": 0,"gas-price": 0.0,
    "prev-block-hash": "","sender": ""}