Skip to content

Commit

Permalink
New topic for accessing time in Sui Move (MystenLabs#9292)
Browse files Browse the repository at this point in the history
## Description 

New topic on accessing time in Move. Navigation entry in future PR.

## Test Plan 

Local

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes

---------

Co-authored-by: Randall-Mysten <109545725+randall-Mysten@users.noreply.github.com>
  • Loading branch information
ronny-mysten and randall-Mysten authored Mar 14, 2023
1 parent 71e9bd1 commit e3bc5cc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions doc/in-progress/time.md → doc/src/build/move/time.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Accessing Time in Move
---
title: Accessing Time in Sui Move
---

You have options when needing to access network-based time for your transactions. If you need a near real-time measurement (within a few seconds), use the immutable reference of time provided by the `Clock` module in Sui Move. The reference value from this module updates with every network checkpoint. If you don't need as current a time slice, use the `epoch_timestamp_ms` function to capture the precise moment the current epoch started.
## `sui::clock::Clock`

To access a prompt timestamp, you must pass a read-only reference of `sui::clock::Clock` as an entry function parameter in your transactions. An instance of `Clock` is provided at address at `0x6`, no new instances can be created.
## The `sui::clock::Clock` module

To access a prompt timestamp, you must pass a read-only reference of `sui::clock::Clock` as an entry function parameter in your transactions. An instance of `Clock` is provided at address `0x6`, no new instances can be created.

Extract a unix timestamp in milliseconds from an instance of `Clock` using

Expand Down Expand Up @@ -38,7 +41,7 @@ A call to the entry function above takes the following form, passing `0x6` as th
$ sui client call --package $EXAMPLE --module 'clock' --function 'access' --args '0x6' --gas-budget 10000
```

**Expect `Clock`'s timestamp to change every 2 to 3 seconds**, at the rate the network commits checkpoints.
**Expect the `Clock` timestamp to change every 2 to 3 seconds**, at the rate the network commits checkpoints.

Successive calls to `sui::clock::timestamp_ms` in the same transaction always produce the same result (transactions are considered to take effect instantly), but timestamps from `Clock` are otherwise monotonic across transactions that touch the same shared objects: Successive transactions seeing a greater or equal timestamp to their predecessors.

Expand Down

0 comments on commit e3bc5cc

Please sign in to comment.