1

I am getting the following error, when I try to submit a transaction that spends 2 script outputs:

Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (MissingRedeemers [(Spending (TxIn (TxId {_unTxId = SafeHash "23e874d6549250c6d845031974212f87edb7f1b1d0f676afdf03cbddaf0ae9ad"}) (TxIx 0)),ScriptHash "d8feffeeee5fe079055719280d2a9603d93dc1289c2dff9912378d51")])),UtxowFailure (FromAlonzoUtxowFail (PPViewHashesDontMatch (SJust (SafeHash "0b672c4621917cc5ff6a62770cbd2841fa419603c43bb0d19d09b45ec184f995")) (SJust (SafeHash "72efce08bafc21afb779a47940e1866b53b4d33da32bc052f15ce80b2e49f5ce")))),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (UtxosFailure (CollectErrors [NoRedeemer (Spending (TxIn (TxId {_unTxId = SafeHash "23e874d6549250c6d845031974212f87edb7f1b1d0f676afdf03cbddaf0ae9ad"}) (TxIx 0)))]))))])

I am currently using the following code to create the Tx inputs:

for (let i = 0; i < sortedScriptTxInputs.length; i++) {
    const o = sortedScriptTxInputs[i];
    const txIn = TransactionInput.new(TransactionHash.from_bytes(Buffer.from(o.txId, 'hex')), o.idx);
    const redeemer = Redeemer.new(
      RedeemerTag.new_spend(),
      BigNum.from_str(`${i}`),     // NOT SURE IF THIS IS THE RIGHT WAY TO INDEX REDEEMERS ?!
      PlutusData.new_empty_constr_plutus_data(BigNum.zero()),
      ExUnits.new(
        BigNum.from_str("7000000"),
        BigNum.from_str("5000000000")
      )
    );
    const plutusWitness = PlutusWitness.new_with_ref(PlutusScriptSource.new(spendingContract), DatumSource.new_ref_input(txIn), redeemer);
    const amt = Value.new(BigNum.from_str(`${o.value.coins}`));
    txBuilder.add_plutus_script_input(plutusWitness, txIn, amt);
}

After adding collateral, I am creating the respective plutus-v2 CostModel and add it like so:

const costModel = TxBuilderConstants.plutus_vasil_cost_models().get(Language.new_plutus_v2());
if (!costModel)
    throw new Error('Missing cost model');
const costModels = Costmdls.new();
costModels.insert(Language.new_plutus_v2(), costModel);
txBuilder.calc_script_data_hash(costModels);

Observation:

If I inspect the redeemer witness set after building the Tx, I would expect to see 2 redeemers but the array only contains 1.

const tx = txBuilder.build_tx();
console.log('Witness Set before signing:');
console.log(tx.witness_set().redeemers()?.to_json());

Output

Witness Set before signing:
[
  {
    "tag": "Spend",
    "index": "1",
    "data": "{\"constructor\":0,\"fields\":[]}",
    "ex_units": {
      "mem": "7000000",
      "steps": "5000000000"
    }
  }
]

What am I missing or constructing wrongly? My suspicion is that I either create invalid indexed redeemers or that txBuilder.calc_script_data_hash or txBuilder.build_tx does not handle multiple redeemers correctly.

Thanks for any help!

3

1 Answer 1

0

There was a bug in the CSL lib for consuming multiple script outputs in one transaction which was resolved by https://github.com/Emurgo/cardano-serialization-lib/issues/536

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.