Module defining the multiple MintCap used across the OriginByte
ecosystem.
Ownership of MintCap is necessary to mint NFTs and can also be used to
delegate the permission to mint NFTs (but not modify collections) using
RegulatedMintCap and UnregulatedMintCap.
Multiple RegulatedMintCap and UnregulatedMintCap can be created
therefore the objects must be securely protected against malicious
access.
An additional restriction placed upon RegulatedMintCap and
UnregulatedMintCap is that they may not be used to further delegate more
mint capabilities.
Structs
mint_cap::MintCap<C> has store, key
mint_cap::MintCap<C> has store, key
Fields:
| Name | Type | Description |
|---|---|---|
id
|
object::UID
|
|
collection_id
|
object::ID
|
ID of the Intended for discovery. |
MintCap<C> delegates the capability to it's owner to mint Nft<C>.
There is only one MintCap per Collection<C>.
This pattern is useful as MintCap can be made shared allowing users
to mint NFTs themselves, such as in a name service application.
mint_cap::UnregulatedMintCap<C> has store, key
mint_cap::UnregulatedMintCap<C> has store, key
Fields:
| Name | Type | Description |
|---|---|---|
id
|
object::UID
|
|
collection_id
|
object::ID
|
ID of the Intended for discovery. |
UnregulatedMintCap delegates the capability to it's owner to mint
Nft from collections with unregulated supply.
mint_cap::RegulatedMintCap<C> has store, key
mint_cap::RegulatedMintCap<C> has store, key
Fields:
| Name | Type | Description |
|---|---|---|
id
|
object::UID
|
|
collection_id
|
object::ID
|
ID of the Intended for discovery. |
supply
|
supply::Supply
|
Supply that |
RegulatedMintCap delegates the capability to it's owner to mint
Nft from collections with regulated supply.
Methods
public(friend) fun new<C>(
collection_id: object::ID,
ctx: &mut tx_context::TxContext,
): mint_cap::MintCap<C>
public(friend) fun new<C>(
collection_id: object::ID,
ctx: &mut tx_context::TxContext,
): mint_cap::MintCap<C>Create a new MintCap
Only one MintCap must exist per collection
public fun collection_id<C>(
mint: &mint_cap::MintCap<C>,
): object::ID
public fun collection_id<C>(
mint: &mint_cap::MintCap<C>,
): object::IDReturns ID of Collection associated with MintCap
public(friend) fun new_unregulated<C>(
_mint_cap: &mint_cap::MintCap<C>,
collection_id: object::ID,
ctx: &mut tx_context::TxContext,
): mint_cap::UnregulatedMintCap<C>
public(friend) fun new_unregulated<C>(
_mint_cap: &mint_cap::MintCap<C>,
collection_id: object::ID,
ctx: &mut tx_context::TxContext,
): mint_cap::UnregulatedMintCap<C>Create a new UnregulatedMintCap
UnregulatedMintCap may only be created by
supply_domain::delegate_unregulated.
public fun delete_unregulated<C>(
mint: mint_cap::UnregulatedMintCap<C>,
)
public fun delete_unregulated<C>(
mint: mint_cap::UnregulatedMintCap<C>,
)Delete UnregulatedMintCap
public fun unregulated_collection_id<C>(
mint: &mint_cap::UnregulatedMintCap<C>,
): object::ID
public fun unregulated_collection_id<C>(
mint: &mint_cap::UnregulatedMintCap<C>,
): object::IDReturns ID of Collection associated with RegulatedMintCap
public(friend) fun new_regulated<C>(
_mint_cap: &mint_cap::MintCap<C>,
collection_id: object::ID,
supply: supply::Supply,
ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>
public(friend) fun new_regulated<C>(
_mint_cap: &mint_cap::MintCap<C>,
collection_id: object::ID,
supply: supply::Supply,
ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>Create a new RegulatedMintCap
RegulatedMintCap may only be created by
supply_domain::delegate_regulated.
public fun from_unregulated<C>(
mint_cap: mint_cap::UnregulatedMintCap<C>,
supply: u64,
ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>
public fun from_unregulated<C>(
mint_cap: mint_cap::UnregulatedMintCap<C>,
supply: u64,
ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>Create a new RegulatedMintCap from UnregulatedMintCap
Presence of UnregulatedMintCap implies that Collection supply is
unregulated, therefore it is safe to create arbitrary
RegulatedMintCap.
public fun delegate<C>(
delegated: &mut mint_cap::RegulatedMintCap<C>,
value: u64,
ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>
public fun delegate<C>(
delegated: &mut mint_cap::RegulatedMintCap<C>,
value: u64,
ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>Creates a new RegulatedMintCap by delegating some supply from an
existing RegulatedMintCap.
Panics
Panics if supply exceeds maximum.
public fun delegate_all<C>(
delegated: &mut mint_cap::RegulatedMintCap<C>,
ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>
public fun delegate_all<C>(
delegated: &mut mint_cap::RegulatedMintCap<C>,
ctx: &mut tx_context::TxContext,
): mint_cap::RegulatedMintCap<C>Creates a new RegulatedMintCap by delegating all remaining supply
from existing RegulatedMintCap.
public fun delete_regulated<C>(
mint: mint_cap::RegulatedMintCap<C>,
): supply::Supply
public fun delete_regulated<C>(
mint: mint_cap::RegulatedMintCap<C>,
): supply::SupplyDelete RegulatedMintCap<C>
public fun regulated_collection_id<C>(
mint: &mint_cap::RegulatedMintCap<C>,
): object::ID
public fun regulated_collection_id<C>(
mint: &mint_cap::RegulatedMintCap<C>,
): object::IDReturns ID of Collection associated with RegulatedMintCap
public fun borrow_supply<C>(
delegated: &mint_cap::RegulatedMintCap<C>,
): &supply::Supply
public fun borrow_supply<C>(
delegated: &mint_cap::RegulatedMintCap<C>,
): &supply::SupplyBorrow RegulatedMintCap Supply
public entry fun increment_supply<C>(
delegated: &mut mint_cap::RegulatedMintCap<C>,
value: u64,
)
public entry fun increment_supply<C>(
delegated: &mut mint_cap::RegulatedMintCap<C>,
value: u64,
)Increments the delegated supply of Inventory
This endpoint must be called before a new Nft object is created to
ensure that global supply tracking remains consistent.
Panics
Panics if delegated supply is exceeded.