cardano/minting

This module incorporates code for various minting and burning validations.

Every function takes the transaction’s mint field (an Assets value) directly, so there is no need to assets.flatten it first. stdlib flags flattening as too expensive for on-chain use.

To read the minted quantity of an asset, use stdlib’s assets.quantity_of(tx.mint, pid, tkn).

Functions

exact(mint: Assets, pid: PolicyId, tkn: AssetName, amt: Int) -> Bool

This checks if a specific policy id, token name, and amount exist inside the mint value. It is searching for an exact match. A positive amt is a mint and a negative amt is a burn. An Assets value never holds a zero quantity, so amt == 0 always returns False.

minting.exact(tx.mint, pid, tkn, 1)

by_prefix(mint: Assets, pid: PolicyId, prefix: ByteArray, amt: Int) -> Bool

This checks if some token under a policy id starts with a prefix and has exactly the amount amt. Instead of searching for an exact token name match, it checks if the token name has the correct prefix. This works if every token name on the policy id is unique. If found then it returns True else False. Prefixes of any length are supported. An empty prefix matches every token name.

minting.by_prefix(tx.mint, pid, cip68.prefix_222, 1)

is_occurring(mint: Assets, pid: PolicyId, tkn: AssetName) -> Bool

Prove that a transaction is minting something from a specific policy id and token name but the amount does not matter. This is great for lock-n-mint style contracts where some logic just needs to check if a mint is occurring but not the specifics of the amount being minted or burned. If a mint or burn is occurring then it will return True else False.

minting.is_occurring(tx.mint, pid, tkn)
Search Document