Module sui::clock
APIs for accessing time from move calls, via the Clock: a unique shared object that is created at 0x6 during genesis.
use std::ascii;
use std::bcs;
use std::option;
use std::string;
use std::vector;
use sui::address;
use sui::hex;
use sui::object;
use sui::party;
use sui::transfer;
use sui::tx_context;
use sui::vec_map;
Struct Clock
Singleton shared object that exposes time to Move calls. This object is found at address 0x6, and can only be read (accessed via an immutable reference) by entry functions.
Entry Functions that attempt to accept Clock by mutable reference or value will fail to verify, and honest validators will not sign or execute transactions that use Clock as an input parameter, unless it is passed by immutable reference.
public struct Clock has key
Fields
- id: sui::object::UID
- timestamp_ms: u64
- The clock's timestamp, which is set automatically by a system transaction every time consensus commits a schedule, or by sui::clock::increment_for_testing during testing.
Constants
Sender is not @0x0 the system address.
const ENotSystemAddress: u64 = 0;
Function timestamp_ms
The clock's current timestamp as a running total of milliseconds since an arbitrary point in the past.
public fun timestamp_ms(clock: &sui::clock::Clock): u64
Function borrow
A reference to the Clock without it being a transaction input.
It is the same Clock, at the same timestamp, as one passed into
the transaction.
New code should read the time this way rather than take a Clock parameter, so that callers do not change when a function starts to need the time. Existing functions with &Clock arguments can be supplied one from anywhere via borrow().
public fun borrow(): &sui::clock::Clock
Function native_borrow
fun native_borrow(): &sui::clock::Clock
Function create
Create and share the singleton Clock -- this function is called exactly once, during genesis.
fun create(ctx: &sui::tx_context::TxContext)
Function consensus_commit_prologue
fun consensus_commit_prologue(clock: &mut sui::clock::Clock, timestamp_ms: u64, ctx: &sui::tx_context::TxContext)