MintCap
A MintCap is an object that serves to guarantee minting authority over a certain type.
For each type T
created for a Collection there is a corresponding type MintCap<T>
. It stands for Mint Capability, and it is object that gives its owner the ability to mint NFTs from its type.
Limited vs. Unlimited Supply
A MintCap<T>
objects can either have the ability to mint an unlimited number of NFTs of its type T
, or a limited amount. This property is defined by its field supply
. Whenever the option mint_cap.supply
is None
it means the supply is unlimited and Some
it means it is limited.
Creating Mint Caps
There are essentially two ways to create a Mintcap
from scratch: We can create it from the Delegated Witness or via the Publisher object.
In the first scenario, you need to acquire DelegatedWitness<T>
and call mint_cap::new()
. Alternatively, we can create the MintCap in conjunction with the collection object by calling collection::create_with_mint_cap()
.
Usually this step is done in the init
function of the contract, but it can also be done at a later stage just by calling the functions in a transaction.
Fungibility
One interest feature of MintCap<T>
is that two mint cap objects of the same type T
are fungible. To split two MintCaps we can call mint_cap::split()
, and to merge we can call mint_cap::merge()
.
Minting Function
The minting function must exist in the contract that is deployed by the creator, and therefore there is no such function in the OriginByte protocol. The reason for this is due to how Move works intrinsically, and only the contract that defines its type is responsible for generating objects of such types. That being said, the purpose of the MintCap is to be used in your mint function interface.
When minting NFTs with limited supply, we add &mut MintCap<T>
to the function signature:
Whereas when minting NFTs with unlimited supply, we only need to add &MintCap<T>
:
Last updated