# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.interestprotocol.com/overview/deprecated/sui-tears/capabilities/timelock.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
