Timelock

It locks any object with the store ability for a specific amount of time. We do not provide a function to read the data inside the {Timelock} to prevent capabilities from being used.

Structs

Timelock

  struct Timelock<T: store> has key, store {
    id: UID,
    unlock_time: u64,
    data: T,
  }
  • unlock_time - The unlock time in milliseconds.

  • data - Any object with the store ability.

Interface

unlock_time

Returns the unlock time in milliseconds.

public fun unlock_time<T: store>(self: &Timelock<T>): u64
  • @param self: A {Timelock}

  • @return u64. The self.unlock_time.

lock

Locks the data for unlock_time milliseconds.

public fun lock<T: store>(
    data: T, 
    c: &Clock,
    unlock_time: u64,
    ctx: &mut TxContext
): Timelock<T>
  • @param data: An object with the store ability.

  • @param c: The shared sui::clock::Clock object.

  • @param unlock_time: The lock period in milliseconds.

  • @return {Timelock}.

Aborts

  • unlock_time is in the past.

unlock

Unlocks a {Timelock} and returns the locked resource T.

public fun unlock<T: store>(self: Timelock<T>, c:&Clock): T
  • @param self: A {Timelock}

  • @param c: The shared sui::clock::Clock object.

  • @return T. An object with the store ability.

Aborts

  • unlock_time has not passed.

Last updated