aiken_design_patterns/tx_level_minter

This design pattern couples the spend and minting endpoints of a validator, in order to have minimal spend costs, in exchange for a single execution of the minting endpoint.

In other words, spend logic only ensures the minting endpoint executes. It does so by looking at the mint field and making sure a non-zero amount of its asset (i.e. with a policy identical to the provided script hash) are getting minted/burnt.

The arbitrary logic is passed to the minting policy so that it can be executed a single time for a given transaction.

Functions

validate_mint(
  mint_script_hash: PolicyId,
  mint: Value,
  redeemers: Pairs<ScriptPurpose, Redeemer>,
  mint_redeemer_index: Int,
  mint_validator: fn(Redeemer, Dict<AssetName, Int>) -> Bool,
) -> Bool

Function primarily meant be used in your spending validator. It looks at both the redeemers, and minted tokens to allow you validate agains the policy’s redeemer, and its tokens getting minted/burnt.

mint_redeemer_index is the positional index of the policy’s redeemer in the redeemers field of the transaction.

validate_mint_minimal(mint_script_hash: PolicyId, mint: Value) -> Bool

A minimal version of spend, where the only validation is presence of at least one minting/burning action with the given policy ID.

Search Document