Skip to content

Fix TransactionBuilderError/EvaluationError in mint.ts and PlutusV2/V3 mismatch in nft.ts#26

Merged
SynthLuvr merged 2 commits into
mainfrom
copilot/debug-token-minting-error
Mar 1, 2026
Merged

Fix TransactionBuilderError/EvaluationError in mint.ts and PlutusV2/V3 mismatch in nft.ts#26
SynthLuvr merged 2 commits into
mainfrom
copilot/debug-token-minting-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

Two bugs introduced during the migration from @lucid-evolution/lucid to @evolution-sdk/evolution and the Aiken v1.0.29-alpha → v1.1.21 upgrade that caused token minting to fail with TransactionBuilderError caused by EvaluationError.

mint.ts: OverlappingAdditionalUtxo → EvaluationError

build() calls lacked availableUtxos, so the SDK fetched on-chain wallet UTxOs from Blockfrost for coin selection. With passAdditionalUtxos: true on the mint tx, those on-chain UTxOs were forwarded to Blockfrost's /utils/txs/evaluate/utxos endpoint as additionalUtxoSet. Since they already exist in Blockfrost's chain database, Blockfrost rejected the request with OverlappingAdditionalUtxo.

Fix: explicitly pass availableUtxos from the simulated chain state to each build() call so coin selection only touches off-chain UTxOs.

Additionally, ref is excluded from the deploy tx's available UTxOs to prevent it from being consumed before the mint tx needs it:

// Before — newTx() arg is ignored by the SDK; availableUtxos not passed to build()
const deployResult = await client
  .newTx(setupUtxos)                          // ← ignored
  .payToAddress({ ... })
  .build({ changeAddress });                  // ← fetches on-chain UTxOs

const mintResult = await client
  .newTx(deployChain.available)               // ← ignored
  .mintAssets({ ... })
  .build({ changeAddress, passAdditionalUtxos: true }); // ← passes on-chain UTxOs to evaluator

// After
const deployUtxos = setupUtxos.filter(
  (u) =>
    TransactionHash.toHex(u.transactionId) !== TransactionHash.toHex(ref.transactionId) ||
    u.index !== ref.index
);
const deployResult = await client
  .newTx()
  .payToAddress({ ... })
  .build({ changeAddress, availableUtxos: deployUtxos });

const mintResult = await client
  .newTx()
  .mintAssets({ ... })
  .build({ changeAddress, availableUtxos: deployChain.available, passAdditionalUtxos: true });

nft.ts: PlutusV2 used for a PlutusV3 validator

nft.ts used PlutusV2 for both createScript and createBlackholeAddress, but multiple.ak compiles to Plutus V3. This is the same mismatch PR #25 fixed in mint.ts. All three PlutusV2 references replaced with PlutusV3.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Comment thread src/mint.ts
Comment thread src/mint.ts
Comment thread src/nft.ts
Copilot AI changed the title [WIP] Debug token minting error in transaction builder Fix TransactionBuilderError/EvaluationError in mint.ts and PlutusV2/V3 mismatch in nft.ts Mar 1, 2026
@SynthLuvr SynthLuvr marked this pull request as ready for review March 1, 2026 16:49
@SynthLuvr SynthLuvr merged commit 3b81ba2 into main Mar 1, 2026
1 check passed
@SynthLuvr SynthLuvr deleted the copilot/debug-token-minting-error branch March 1, 2026 16:49
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