2

What is the meaning of the index in the redeemer ?

redeemer = [ tag: redeemer_tag, index: uint, data: plutus_data, ex_units: ex_units 

for context see:

https://github.com/input-output-hk/cardano-ledger/blob/master/eras/alonzo/test-suite/cddl-files/alonzo.cddl

I think in Serialization version 9 it used to be the index of the inputs. There was even a method for getting the index of the input in the class Transaction Builder. But now in 10.4 this method is not longer available and in fact for the experiments i have done so far the index of the redeemer needed for the transaction to be validated by the node seems not to be the same as the index of the input in the transaction, so I have not a method for computing the index that i should attach to the redeemer.

2
  • did you figure this out .?
    – Dawar Ejaz
    Aug 24, 2022 at 8:38
  • Yes, order them by alphanumeric... Y Not by the order they are added Aug 25, 2022 at 11:33

1 Answer 1

2

I was digging in this topic because I struggled with some transactions. I was reading the CDLL, the serialization lib, docs, etc.. but I couldn't find anything about the meaning of this index.

After some research in the cardano node source code, I found that the index is referred to the TxIn but those must be ordered alphabetical.

Here is some code from the cardano-node:

    scriptWitnessesTxIns
      :: [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
      -> [(ScriptWitnessIndex, AnyScriptWitness era)]
    scriptWitnessesTxIns txins =
        [ (ScriptWitnessIndexTxIn ix, AnyScriptWitness witness)
          -- The tx ins are indexed in the map order by txid
        | (ix, (_, BuildTxWith (ScriptWitness _ witness)))
            <- zip [0..] (orderTxIns txins)
        ]

My problem was that I was using this index according to the add order with the add_plutus_script_input and add_input method.

I hope it helps.

2
  • What tool are you using to make the transactions? Jun 5, 2022 at 23:11
  • 1
    I'm using the Cardano serialization lib and a own version of the cardano-js-sdk from IOHK
    – Juantxu
    Jun 6, 2022 at 22:20

Your Answer

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

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