Skip to content

Require redeemer equal to tx_id in mint validator#36

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/update-mint-redeemer-validation
Closed

Require redeemer equal to tx_id in mint validator#36
Copilot wants to merge 2 commits into
mainfrom
copilot/update-mint-redeemer-validation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 2, 2026

The mint validator accepted but ignored its redeemer. This adds enforcement: the redeemer must equal the tx_id script parameter, and mint.ts supplies it accordingly.

Validator (validators/mint.ak)

  • Replaced _redeemer with a typed redeemer: Hash<Blake2b_256, Transaction>
  • Added redeemer == tx_id assertion gating the rest of the mint logic
mint(redeemer: Hash<Blake2b_256, Transaction>, policy: PolicyId, self: Transaction) {
  let reference = OutputReference { transaction_id: tx_id, output_index: index }
  let Transaction { inputs, mint, .. } = self
  redeemer == tx_id && mint_validator(policy, reference, inputs, mint)
}

Off-chain (src/mint.ts)

  • Passes TransactionHash.toBytes(ref.transactionId) as the redeemer in mintAssets, providing the tx_id bytes expected by the validator
.mintAssets({
  assets: Assets.fromRecord({ [token]: amount }),
  redeemer: TransactionHash.toBytes(ref.transactionId),
})

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…emer in mint.ts

Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Comment thread src/mint.ts
Comment thread src/mint.ts
Copilot AI changed the title [WIP] Update mint function to validate redeemer against tx_id Require redeemer equal to tx_id in mint validator Mar 2, 2026
@SynthLuvr SynthLuvr closed this Mar 2, 2026
@SynthLuvr SynthLuvr deleted the copilot/update-mint-redeemer-validation branch March 2, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants