> For the complete documentation index, see [llms.txt](https://docs.talus.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.talus.network/reference/move/nexus_primitives/owner_cap.md).

# owner\_cap

* [Struct `CloneableOwnerCap`](#struct-cloneableownercap)
  * [Important](#important)
* [Struct `OwnerCap`](#struct-ownercap)
  * [Important](#important-1)
* [Constants](#constants)
* [Function `new_uncloneable`](#function-new_uncloneable)
* [Function `new_cloneable_drop`](#function-new_cloneable_drop)
* [Function `new_cloneable_key`](#function-new_cloneable_key)
* [Function `clone`](#function-clone)
* [Function `clone_n`](#function-clone_n)
* [Function `clone_for_receiver`](#function-clone_for_receiver)
* [Function `destroy`](#function-destroy)
* [Function `id`](#function-id)
* [Function `what_for`](#function-what_for)
* [Function `is_for`](#function-is_for)
* [Function `is_for_id`](#function-is_for_id)
* [Function `as_ref`](#function-as_ref)

### Struct `CloneableOwnerCap`

When you want to prove you own something.

The pattern of usage: Authorize with [`what_for`](#nexus_primitives_owner_cap_what_for) UID value of the resource and assert [`what_for`](#nexus_primitives_owner_cap_what_for) from the resource's module. In this case \[clone] is useful to allow multiple addresses or multiple concurrent txs.

#### Important

The generic parameter `T` is a phantom type that is used to distinguish between different things that can be owned.

a. `T has drop` then \[CloneableOwnerCap] can be created only by giving `T` b. `T has store` then \[CloneableOwnerCap] can be created by giving `&T` and associated \[UID].

```move
public struct CloneableOwnerCap<phantom T> has key, store
```

<details>

<summary>Fields</summary>

[`id`](#nexus_primitives_owner_cap_id)`: sui::object::UID`[`what_for`](#nexus_primitives_owner_cap_what_for)`: sui::object::ID`ID of the resource controlled by this capability.`inner:` [`nexus_primitives::owner_cap::OwnerCap`](#nexus_primitives_owner_cap_OwnerCap)`<T>`Some packages might not care about the [`what_for`](#nexus_primitives_owner_cap_what_for) field, so they accept \[OwnerCap]. This allows us to emulate Rust's `AsRef` trait. Similar pattern for \[sui::coin] and \[sui::balance].

</details>

#### Struct `OwnerCap`

When you want to prove you own something.

The pattern of usage: Store the \[OwnerCap] ID in a resource and assert from the resource's module that the sender has the right \[OwnerCap]'s ID.

**Important**

The generic parameter `T` is a phantom type that is used to distinguish between different things that can be owned. Anyone with a reference to \[T] can create an \[OwnerCap] with its generic.

```move
public struct OwnerCap<phantom T> has drop, store
```

<details>

<summary>Fields</summary>

`unique: sui::object::ID`

</details>

#### Constants

```move
#[error]
const EObjectUidMismatch: vector<u8> = b"Object key must match provided UID";
```

#### Function `new_uncloneable`

Creates a non-cloneable ownership capability with a fresh unique ID. Anyone holding a reference to `T` can mint one.

```move
public fun new_uncloneable<T>(_: &T, ctx: &mut sui::tx_context::TxContext): nexus_primitives::owner_cap::OwnerCap<T>
```

#### Function `new_cloneable_drop`

Creates cloneable authority over [`what_for`](#nexus_primitives_owner_cap_what_for) from a consumable role witness.

```move
public fun new_cloneable_drop<T: drop>(witness: T, what_for: &sui::object::UID, ctx: &mut sui::tx_context::TxContext): nexus_primitives::owner_cap::CloneableOwnerCap<T>
```

#### Function `new_cloneable_key`

Creates cloneable authority over an object after verifying its UID.

```move
public fun new_cloneable_key<T: key>(object: &T, its_uid: &sui::object::UID, ctx: &mut sui::tx_context::TxContext): nexus_primitives::owner_cap::CloneableOwnerCap<T>
```

#### Function `clone`

Creates a new \[CloneableOwnerCap] with the same [`what_for`](#nexus_primitives_owner_cap_what_for).

```move
public fun clone<T>(cap: &nexus_primitives::owner_cap::CloneableOwnerCap<T>, ctx: &mut sui::tx_context::TxContext): nexus_primitives::owner_cap::CloneableOwnerCap<T>
```

#### Function `clone_n`

Creates N new \[CloneableOwnerCap]s with the same [`what_for`](#nexus_primitives_owner_cap_what_for).

```move
public fun clone_n<T>(cap: &nexus_primitives::owner_cap::CloneableOwnerCap<T>, n: u64, ctx: &mut sui::tx_context::TxContext): vector<nexus_primitives::owner_cap::CloneableOwnerCap<T>>
```

#### Function `clone_for_receiver`

Creates a new \[CloneableOwnerCap] with the same [`what_for`](#nexus_primitives_owner_cap_what_for) and transfers it to the given address.

```move
public fun clone_for_receiver<T>(cap: &nexus_primitives::owner_cap::CloneableOwnerCap<T>, receiver: address, ctx: &mut sui::tx_context::TxContext)
```

#### Function `destroy`

Destroys a cloneable capability and drops its inner authority token.

```move
public fun destroy<T>(self: nexus_primitives::owner_cap::CloneableOwnerCap<T>)
```

#### Function `id`

The capability's unique ID.

```move
public fun id<T>(self: &nexus_primitives::owner_cap::OwnerCap<T>): sui::object::ID
```

#### Function `what_for`

The ID of the resource this capability owns.

```move
public fun what_for<T>(self: &nexus_primitives::owner_cap::CloneableOwnerCap<T>): sui::object::ID
```

#### Function `is_for`

Whether this capability owns the given object.

```move
public fun is_for<T, U: key>(self: &nexus_primitives::owner_cap::CloneableOwnerCap<T>, what: &U): bool
```

#### Function `is_for_id`

Whether this capability owns the resource with the given ID.

```move
public fun is_for_id<T>(self: &nexus_primitives::owner_cap::CloneableOwnerCap<T>, what_id: sui::object::ID): bool
```

#### Function `as_ref`

Borrows the inner non-cloneable [`OwnerCap`](#nexus_primitives_owner_cap_OwnerCap) for APIs that care about authority identity but not resource binding. This provides the same view-style pattern used to expose narrower coin or balance capabilities.

```move
public fun as_ref<T>(self: &nexus_primitives::owner_cap::CloneableOwnerCap<T>): &nexus_primitives::owner_cap::OwnerCap<T>
```


---

# 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 following URL with the `ask` and `goal` query parameters:

```
GET https://docs.talus.network/reference/move/nexus_primitives/owner_cap.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

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.
