> 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/object_state.md).

# nexus\_primitives::object\_state

* [Struct `Inner`](#struct-inner)
* [Struct `Witness`](#struct-witness)
* [Constants](#constants)
* [Function `add`](#function-add)
* [Function `inner`](#function-inner)
* [Function `inner_mut`](#function-inner_mut)
* [Function `has_witness`](#function-has_witness)
* [Function `assert_witness`](#function-assert_witness)
* [Function `replace_witness`](#function-replace_witness)
* [Function `take_inner`](#function-take_inner)
* [Function `add_inner`](#function-add_inner)
* [Function `destroy`](#function-destroy)
* [Function `assert_upgrade_cap`](#function-assert_upgrade_cap)

### Struct `Inner`

Positional key for an object's exact stored layout.

A shared key is required because each object module must expose the same observable storage position without sharing its stored value type.

```move
public struct Inner has copy, drop, store
```

<details>

<summary>Fields</summary>

</details>

#### Struct `Witness`

Positional key for the package an object accepts as write authority.

This is separate from \[[`Inner`](#nexus_primitives_object_state_Inner)] because execution can change without a storage layout change.

```move
public struct Witness has copy, drop, store
```

<details>

<summary>Fields</summary>

</details>

#### Constants

```move
#[error]
const EWrongWitness: vector<u8> = b"Object does not accept this package witness";
```

```move
#[error]
const EWrongUpgradeCap: vector<u8> = b"Upgrade capability does not target the witness package";
```

#### Function `add`

Attach one stored layout and one package witness to a stable object.

```move
public fun add<W: store, I: store>(id: &mut sui::object::UID, witness: W, inner: I)
```

#### Function `inner`

Borrow the exact stored layout without changing package authority.

```move
public fun inner<I: store>(id: &sui::object::UID): &I
```

#### Function `inner_mut`

Borrow the exact stored layout after verifying package authority.

```move
public fun inner_mut<W: store, I: store>(id: &mut sui::object::UID): &mut I
```

#### Function `has_witness`

Return whether the object accepts the exact witness type.

```move
public fun has_witness<W: store>(id: &sui::object::UID): bool
```

#### Function `assert_witness`

Require the object to accept the exact witness type.

```move
public fun assert_witness<W: store>(id: &sui::object::UID)
```

#### Function `replace_witness`

Replace an exact source witness with an exact target witness.

```move
public fun replace_witness<Old: drop, store, New: store>(id: &mut sui::object::UID, witness: New)
```

#### Function `take_inner`

Remove and return the exact stored layout during a declared transition.

```move
public fun take_inner<I: store>(id: &mut sui::object::UID): I
```

#### Function `add_inner`

Attach the target layout during a declared transition.

```move
public fun add_inner<I: store>(id: &mut sui::object::UID, inner: I)
```

#### Function `destroy`

Destroy a stable identity after removing its typed fields.

The inner value is returned because only its defining module knows how to destroy resources contained by that layout.

```move
public fun destroy<W: drop, store, I: store>(id: sui::object::UID): I
```

#### Function `assert_upgrade_cap`

Require an upgrade capability whose latest package introduced `W`.

```move
public fun assert_upgrade_cap<W>(cap: &sui::package::UpgradeCap)
```


---

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