Skip to content

Fix script validation failures: PlutusV2→V3 and missing CBOR encoding in zero.ts and distribute.ts#34

Merged
SynthLuvr merged 5 commits into
mainfrom
copilot/debug-missing-redeemers-error
Mar 2, 2026
Merged

Fix script validation failures: PlutusV2→V3 and missing CBOR encoding in zero.ts and distribute.ts#34
SynthLuvr merged 5 commits into
mainfrom
copilot/debug-missing-redeemers-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

Aiken compiles validators to PlutusV3, but zero.ts and distribute.ts were wrapping script bytes as PlutusV2 and skipping the required applySingleCborEncoding step — causing script validation failure at the wrong language version with malformed script bytes.

Changes

  • src/zero.ts and src/distribute.ts: PlutusV2PlutusV3 throughout (createScript + createBlackholeAddress)
  • src/zero.ts and src/distribute.ts: Wrap applyParamsToScript with applySingleCborEncodingapplyParamsToScript returns double-CBOR-encoded bytes; PlutusV3 requires single-CBOR-encoded bytes
// Before
const scriptHex = UPLC.applyParamsToScript(plutus, [...]);
return new PlutusV2({ bytes: hexToBytes(scriptHex) });

// After
const scriptHex = UPLC.applySingleCborEncoding(
  UPLC.applyParamsToScript(plutus, [...])
);
return new PlutusV3({ bytes: hexToBytes(scriptHex) });

Also removes the erroneously added redeemer: Data.constr(0n, []) from all mintAssets calls — Plutus V3 minting policies do not require redeemers, and passing one causes validation failure.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Comment thread src/mint.ts
Comment thread src/mint.ts Outdated
Copilot AI changed the title [WIP] Fix missing redeemers for Plutus scripts in minting Fix missing redeemer on Plutus mint transaction Mar 1, 2026
Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Copilot AI changed the title Fix missing redeemer on Plutus mint transaction Use Data.constr factory instead of new Data.Constr constructor Mar 1, 2026
Comment thread src/burn.ts
Comment thread src/distribute.ts
Comment thread src/distribute.ts
Comment thread src/nft.ts
Comment thread src/nft.ts
Comment thread src/zero.ts
Comment thread src/zero.ts
Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Copilot AI changed the title Use Data.constr factory instead of new Data.Constr constructor Remove redeemers from Plutus V3 minting policy calls Mar 1, 2026
…distribute.ts

Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Comment thread src/distribute.ts
Comment thread src/zero.ts
Copilot AI changed the title Remove redeemers from Plutus V3 minting policy calls Fix script validation failures: PlutusV2→V3 and missing CBOR encoding in zero.ts and distribute.ts Mar 1, 2026
@SynthLuvr SynthLuvr marked this pull request as ready for review March 2, 2026 06:45
@SynthLuvr SynthLuvr merged commit 9d2fe45 into main Mar 2, 2026
1 check passed
@SynthLuvr SynthLuvr deleted the copilot/debug-missing-redeemers-error branch March 2, 2026 06:45
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