> For the complete documentation index, see [llms.txt](https://docs.interestprotocol.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.interestprotocol.com/overview/deprecated/sui-tears/capabilities/timelock.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
