Skip to content

BlockfrostEffect.evaluateTx drops reference script in additionalUtxoSet (causes missingRequiredScripts) #166

@SynthLuvr

Description

@SynthLuvr

BlockfrostEffect.evaluateTx constructs the additionalUtxoSet payload used with Blockfrost’s /utils/txs/evaluate/utxos endpoint, but silently drops the script field from each UTxO’s txOut. When a mint transaction references an unconfirmed deploy UTxO that carries the minting policy as a reference script, Blockfrost evaluation fails with missingRequiredScripts.

Affected version

  • @evolution-sdk/evolution@0.3.19 (observed)
  • Likely affects any versions where evaluateTx maps additionalUTxOs without including the script field.

What happens

When passAdditionalUtxos: true is used (or otherwise supplying additional UTxOs to evaluation), evaluateTx builds the payload’s additionalUtxoSet, but the resulting txOut only includes value/address and datum/datumHash, and never includes txOut.script even if the provided UTxO has a script (reference script).

This breaks evaluation when:

  • The mint tx uses readFrom({ referenceInputs }) to reference the policy script, and
  • That reference script UTxO is not yet confirmed on-chain (so Blockfrost must rely on additionalUtxoSet), and
  • The script is required to evaluate the transaction.

Expected behavior

If an additional UTxO includes a reference script, evaluateTx should include it in the Blockfrost payload:

  • additionalUtxoSet[].txOut.script should be populated when present.

Actual behavior

evaluateTx drops utxo.script while mapping additionalUTxOs to Blockfrost’s additionalUtxoSet schema, resulting in missingRequiredScripts during evaluation.

Error observed

Blockfrost evaluation returns missingRequiredScripts when the mint transaction references an unconfirmed deploy/reference-script UTxO carrying the minting policy.

Reproduction (high level)

  1. Create a deploy transaction that produces a UTxO with the policy script stored as a reference script.

  2. Before that deploy UTxO is confirmed, build a mint transaction that:

    • references the deploy UTxO via readFrom({ referenceInputs: [refScript] })
    • enables passing additional UTxOs for evaluation (passAdditionalUtxos: true)
  3. Call the SDK’s Blockfrost evaluation path (uses /utils/txs/evaluate/utxos).

  4. Evaluation fails with missingRequiredScripts because the reference script is absent from additionalUtxoSet.

Root cause

In src/sdk/provider/internal/BlockfrostEffect.ts, evaluateTx maps additionalUTxOs into [txIn, txOut] tuples for the payload. The mapping handles datum/datumHash, but does not copy over utxo.script into txOut.script.

Proposed fix

Include the script field in txOut when present:

+ // Add script if present (required for reference script UTxOs)
+ if (utxo.script) {
+   txOut.script = utxo.script;
+ }

Patch (applied locally)

I applied a patch-package patch against 0.3.19 to both the .ts source and compiled .js output:

  • node_modules/@evolution-sdk/evolution/src/sdk/provider/internal/BlockfrostEffect.ts
  • node_modules/@evolution-sdk/evolution/dist/sdk/provider/internal/BlockfrostEffect.js

Patch excerpt:

@@
   } else if (utxo.datumHash) {
     txOut.datumHash = utxo.datumHash;
   }
+  // Add script if present (required for reference script UTxOs)
+  if (utxo.script) {
+    txOut.script = utxo.script;
+  }
   return [txIn, txOut];

Related notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions