> 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/talus-docs-v2.1.0/reference/move/nexus_tool/finite_credits.md).

# nexus\_tool::finite\_credits

* [Struct `Policy`](#struct-policy)
* [Struct `Config`](#struct-config)
* [Struct `State`](#struct-state)
* [Struct `CreditReserve`](#struct-creditreserve)
* [Struct `CreditsCreatedEvent`](#struct-creditscreatedevent)
* [Struct `CreditOfferChangedEvent`](#struct-creditofferchangedevent)
* [Constants](#constants)
* [Function `enable`](#function-enable)
* [Function `buy`](#function-buy)
* [Function `buy_more`](#function-buy_more)
* [Function `close_issuance`](#function-close_issuance)
* [Function `open_issuance`](#function-open_issuance)
* [Function `update_terms`](#function-update_terms)
* [Function `offer`](#function-offer)
* [Function `issue`](#function-issue)
* [Function `issue_more`](#function-issue_more)
* [Function `get_invocation`](#function-get_invocation)
* [Function `restore_refund`](#function-restore_refund)
* [Function `collect`](#function-collect)
* [Function `share`](#function-share)
* [Function `remaining`](#function-remaining)
* [Function `derive_id`](#function-derive_id)

### Struct `Policy`

Private construction witness for this policy.

```move
public struct Policy has drop
```

<details>

<summary>Fields</summary>

</details>

#### Struct `Config`

Owner configured sale terms for finite credits.

```move
public struct Config has store
```

<details>

<summary>Fields</summary>

`issuance_enabled: boolprice_per_credit: u64minimum_credits: u64maximum_credits: u64`

</details>

#### Struct `State`

Policy state stored in one beneficiary's canonical account.

```move
public struct State has store
```

<details>

<summary>Fields</summary>

[`remaining`](#nexus_tool_finite_credits_remaining)`: u64`

</details>

#### Struct `CreditReserve`

One prepaid unit held by an in flight \[Invocation].

\[CreditReserve] carries no SUI. Payment occurs when credits are purchased; this marker preserves one unit until finalization or refund.

```move
public struct CreditReserve has store
```

<details>

<summary>Fields</summary>

</details>

#### Struct `CreditsCreatedEvent`

Records creation of one canonical finite credit \[PolicyAccount].

```move
public struct CreditsCreatedEvent has copy, drop
```

<details>

<summary>Fields</summary>

`tool: sui::object::IDcashier: sui::object::IDcredits: sui::object::IDbeneficiary:` [`nexus_interface::payment::PaymentSourceKind`](/talus-docs-v2.1.0/reference/move/nexus_interface/payment.md#nexus_interface_payment_PaymentSourceKind)[`remaining`](#nexus_tool_finite_credits_remaining)`: u64`

</details>

#### Struct `CreditOfferChangedEvent`

Records the complete commercial offer for future credit purchases.

```move
public struct CreditOfferChangedEvent has copy, drop
```

<details>

<summary>Fields</summary>

`cashier: sui::object::IDissuance_enabled: boolprice_per_credit: u64minimum_credits: u64maximum_credits: u64`

</details>

#### Constants

```move
#[error]
const ECreditsMismatch: vector<u8> = b"Credits do not authorize this invocation request";
```

```move
#[error]
const EInvalidCreditCount: vector<u8> = b"Credit count is outside the configured range";
```

```move
#[error]
const EInvalidCreditRange: vector<u8> = b"Credit range must start above zero";
```

```move
#[error]
const EInvalidCreditPrice: vector<u8> = b"Credit price must be greater than zero";
```

```move
#[error]
const EIssuanceClosed: vector<u8> = b"Finite credit issuance is closed";
```

```move
#[error]
const ENoCreditsRemaining: vector<u8> = b"No invocation credits remain";
```

```move
#[error]
const ECreditOverflow: vector<u8> = b"Invocation credit count overflow";
```

#### Function `enable`

Enables finite credit admission and sales.

```move
public fun enable(cashier: &mut nexus_tool::tool_cashier::ToolCashier, owner_cap: &nexus_primitives::owner_cap::CloneableOwnerCap<nexus_tool::tool_cashier::OverToolCashier>, price_per_credit: u64, minimum_credits: u64, maximum_credits: u64)
```

#### Function `buy`

Purchases credits, shares the canonical policy account, and transfers prepaid SUI to the cashier inbox. The public call returns only the deposit ID.

```move
public fun buy(cashier: &mut nexus_tool::tool_cashier::ToolCashier, pay_with: &mut sui::coin::Coin<sui::sui::SUI>, beneficiary: nexus_interface::payment::PaymentSourceKind, credits: u64, ctx: &mut sui::tx_context::TxContext): sui::object::ID
```

#### Function `buy_more`

Purchases units for an existing canonical credit account.

```move
public fun buy_more(cashier: &nexus_tool::tool_cashier::ToolCashier, credits: &mut nexus_tool::tool_cashier::PolicyAccount<nexus_tool::finite_credits::Policy, nexus_tool::finite_credits::State>, pay_with: &mut sui::coin::Coin<sui::sui::SUI>, additional_credits: u64, ctx: &mut sui::tx_context::TxContext): sui::object::ID
```

#### Function `close_issuance`

Stops purchases and owner issuance without invalidating existing accounts.

```move
public fun close_issuance(cashier: &mut nexus_tool::tool_cashier::ToolCashier, owner_cap: &nexus_primitives::owner_cap::CloneableOwnerCap<nexus_tool::tool_cashier::OverToolCashier>)
```

#### Function `open_issuance`

Resumes purchases and owner issuance for canonical credit accounts.

```move
public fun open_issuance(cashier: &mut nexus_tool::tool_cashier::ToolCashier, owner_cap: &nexus_primitives::owner_cap::CloneableOwnerCap<nexus_tool::tool_cashier::OverToolCashier>)
```

#### Function `update_terms`

Replaces the sale terms used only for future purchases and grants.

```move
public fun update_terms(cashier: &mut nexus_tool::tool_cashier::ToolCashier, owner_cap: &nexus_primitives::owner_cap::CloneableOwnerCap<nexus_tool::tool_cashier::OverToolCashier>, price_per_credit: u64, minimum_credits: u64, maximum_credits: u64)
```

#### Function `offer`

Returns the current finite credit offer.

```move
public fun offer(cashier: &nexus_tool::tool_cashier::ToolCashier): (bool, u64, u64, u64)
```

#### Function `issue`

Issues credits under Tool owner authority.

```move
public fun issue(cashier: &mut nexus_tool::tool_cashier::ToolCashier, owner_cap: &nexus_primitives::owner_cap::CloneableOwnerCap<nexus_tool::tool_cashier::OverToolCashier>, beneficiary: nexus_interface::payment::PaymentSourceKind, credits: u64, ctx: &mut sui::tx_context::TxContext): nexus_tool::tool_cashier::PolicyAccount<nexus_tool::finite_credits::Policy, nexus_tool::finite_credits::State>
```

#### Function `issue_more`

Adds an owner granted amount to an existing canonical credit account.

```move
public fun issue_more(cashier: &nexus_tool::tool_cashier::ToolCashier, credits: &mut nexus_tool::tool_cashier::PolicyAccount<nexus_tool::finite_credits::Policy, nexus_tool::finite_credits::State>, owner_cap: &nexus_primitives::owner_cap::CloneableOwnerCap<nexus_tool::tool_cashier::OverToolCashier>, additional_credits: u64)
```

#### Function `get_invocation`

Decrements \[State] and creates an \[Invocation] holding one prepaid unit.

The held \[CreditReserve] is a unit marker, not an execution payment reserve. The Invocation therefore records zero SUI and names \[credits] as its exact accounting source.

```move
public fun get_invocation(cashier: &nexus_tool::tool_cashier::ToolCashier, credits: &mut nexus_tool::tool_cashier::PolicyAccount<nexus_tool::finite_credits::Policy, nexus_tool::finite_credits::State>, request: nexus_interface::payment::InvocationRequest, ctx: &mut sui::tx_context::TxContext): nexus_tool::invocation::Invocation
```

#### Function `restore_refund`

Restores one exact refunded unit to its canonical credit account.

```move
public fun restore_refund(credits: &mut nexus_tool::tool_cashier::PolicyAccount<nexus_tool::finite_credits::Policy, nexus_tool::finite_credits::State>, receiving: sui::transfer::Receiving<nexus_tool::invocation::Invocation>)
```

#### Function `collect`

Collects finalized credit Invocations and consumes their reserved units.

```move
public fun collect(cashier: &mut nexus_tool::tool_cashier::ToolCashier, owner_cap: &nexus_primitives::owner_cap::CloneableOwnerCap<nexus_tool::tool_cashier::OverToolCashier>, invocations: vector<sui::transfer::Receiving<nexus_tool::invocation::Invocation>>): sui::balance::Balance<sui::sui::SUI>
```

#### Function `share`

Shares a canonical credit \[PolicyAccount] for runtime admission.

```move
public fun share(credits: nexus_tool::tool_cashier::PolicyAccount<nexus_tool::finite_credits::Policy, nexus_tool::finite_credits::State>)
```

#### Function `remaining`

Returns the units currently available in \[self].

```move
public fun remaining(self: &nexus_tool::tool_cashier::PolicyAccount<nexus_tool::finite_credits::Policy, nexus_tool::finite_credits::State>): u64
```

#### Function `derive_id`

Derives the canonical finite credit account for \[beneficiary].

```move
public fun derive_id(cashier: sui::object::ID, beneficiary: nexus_interface::payment::PaymentSourceKind): sui::object::ID
```


---

# 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/talus-docs-v2.1.0/reference/move/nexus_tool/finite_credits.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.
