# 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

### <mark style="color:blue;">**Timelock**</mark>

```rust
  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

### <mark style="color:blue;">unlock\_time</mark>

**Returns the unlock time in milliseconds.**

```rust
public fun unlock_time<T: store>(self: &Timelock<T>): u64
```

* **@param self:** A {Timelock}
* **@return** u64. The `self.unlock_time`.

### <mark style="color:blue;">lock</mark>

**Locks the `data` for `unlock_time` milliseconds.**

```rust
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.

### <mark style="color:blue;">unlock</mark>

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

```rust
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.
