# Owner

It provides an Owner capability that stores the IDs of other objects, Modules can assert or check if a certain ID is stored in the Owner to prove its ownership. It is used to provide access control.&#x20;

## Structs

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

```rust
struct OwnerCap<phantom T> has key, store {
    id: UID,
    of: VecSet<ID>
 }
```

* **of - A set of IDs to prove that the Owner Capability has privileged access to it.**&#x20;

## Interface

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

**It creates an OwnerCap capability.**&#x20;

```rust
public fun new<T: drop>(_: T, of: vector<ID>, ctx: &mut TxContext): OwnerCap<T>
```

* **@param \_:** A witness to link an OwnerCap with the module that owns the witness.
* **@param of:** Vector of `sui::object::ID` that this capability owns.
* **@return** OwnerCap.

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

**It checks if an ID is stored in the Owner Capability.**&#x20;

```rust
public fun contains<T: drop>(self: &OwnerCap<T>, x: ID): bool 
```

* **@param self:** An OwnerCap object.
* **@param x:** The `sui::object::ID` of an object.
* **@return** bool. True if the `self` owns `x`.

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

**Returns the vector of `sui::object::ID` that the `self` owns.**

```rust
public fun of<T: drop>(self: &OwnerCap<T>): vector<ID>
```

* **@param self:** A {OwnerCap} object.
* **@return** vector. The vector of `sui::object::ID`.

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

**Assigns the `self` OwnerCap as the owner of `x`.**

```rust
public fun add<T: drop>(self: &mut OwnerCap<T>, _: T, x: ID)
```

* **@param self:** An OwnerCap object.
* **@param \_:** A witness to make sure only the allowed module can add `sui::object::ID` to the self.
* **@param x:** The `sui::object::ID` of the object, which the `self` will have ownership rights to.

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

**Removes the `self` OwnerCap as the owner of `x`.**

```rust
public fun remove<T: drop>(self: &mut OwnerCap<T>, _: T, x: ID)
```

* **@param self:** An OwnerCap object.
* **@param \_:** A witness to make sure only the right module can add the `sui::object::ID` to the self.
* **@param x:** The `sui::object::ID` of the object, which the `self` will lose its ownership rights to.

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

**Destroys an OwnerCap. It does not require the of vector to be empty.**

```rust
public fun destroy<T: drop>(self: OwnerCap<T>)
```

* **@param self:** An OwnerCap object.

### <mark style="color:blue;">destroy\_empty</mark>

**Destroys an OwnerCap. It requires the of vector to be empty.**

```rust
public fun destroy<T: drop>(self: OwnerCap<T>)
```

* **@param self:** A OwnerCap object.

**Aborts**

* If `of` vector is not empty.&#x20;

### <mark style="color:blue;">assert\_ownership</mark>

**Asserts that the `self` owns `x`.**

```rust
public fun destroy<T: drop>(self: OwnerCap<T>)
```

* **@param self:** An OwnerCap object.
* **@param x:** The `sui::object::ID` of the object, which must belong to the capability.

**Aborts**

* If the ID is not owned by the capability.


---

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