For the complete documentation index, see llms.txt. This page is also available as Markdown.

Build

Step-by-step instructions for building a custom Storage Unit extension. For concepts and design, see the Storage Unit README.

Prerequisites

High-level steps

  1. Define a witness struct (e.g. public struct VendingAuth has drop {}) in your Move package.

  2. Implement your logic so it calls the world storage unit module to deposit or withdraw items using your Auth witness (e.g. after checking payment, tribe, or other rules).

  3. Publish the package and authorize it on the storage unit: borrow the storage unit’s OwnerCap and call storage_unit::authorize_extension<YourAuth>.

After authorization, only your extension’s logic can perform deposits/withdrawals for non-owner characters; the world module checks the Auth type.

Storage Unit API

Custom contracts use the typed witness pattern: define a witness struct (Auth) and register it on the storage unit.

Authorize an extension:

public fun authorize_extension<Auth: drop>(
    storage_unit: &mut StorageUnit,
    owner_cap: &OwnerCap<StorageUnit>,
)

Extension: deposit / withdraw (main inventory; your extension calls these with your Auth witness):

Extension: deposit into a player’s owned inventory Lets the extension push items into a specific character’s owned inventory; the recipient does not need to be the transaction sender. Use for async delivery, guild hangars, rewards:

Owner deposit / withdraw (no extension; owner uses OwnerCap; sender must be the character).

Example use cases: vending machine (pay then withdraw), trade hub, gated access. See builder-scaffold storage unit extension for a working example.

Reference

Last updated