1

I am consuming a script output and also create a new one at the same script address. The validator script requires the output producer to provide the datum value due to making assertions on it. Therefore, I would like to know how can I provide a datum value for creating an output using the cardano serialization lib and not just the datum hash!

The only thing I saw was something called TransactionBuilder.set_auxiliary_data() but I am not sure whether that fits what I need.

Thanks for any advice in the right direction.

Currently I am doing something like this which obviously only provides the datum hash - not the value.

txBuilder.add_output(
    TransactionOutputBuilder.new()
        .with_address(scriptAddress)
        .with_data_hash(hash_plutus_data(myDatum))
        .next()
        .with_value(Value.new(amount))
        .build()
);

1 Answer 1

1

Thanks to Sebastien, there is an open issue for this. Github Feature Request

Besides, one can attach the datum separately to the tx witness set, like so for example:

const datums = PlutusList.new();
datums.add(datumOfCurrentOutputToBeConsumed);
datums.add(datumOfNewOutputToBeCreated);

const transactionWitnessSet = TransactionWitnessSet.new();
transactionWitnessSet.set_plutus_data(datums);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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