Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Strange behavior of toCardanoTxBody (missing datums) #139

@anton-k

Description

@anton-k

Summary

I try to test my contracts with functions toCardanoTxBody and evaulateTransactionExecutionUnits.
I build Plutus Tx by hand and convert it to cardano Tx to use evaluation function.

Something strange happens when I update datum from the input to output on the same address.
It can not find datum by datum hash. The function that I use to create part of Tx that pays to script:

-- | Pay to the script.
payToScript :: ToData (DatumType a) => TypedValidator a -> DatumType a -> Value -> Tx
payToScript tv dat val =
  mempty
    { txOutputs = [TxOut (validatorAddress tv) val (Just dh)]
    , txData = M.singleton dh datum
    }
  where
    dh = datumHash datum
    datum = Datum $ toBuiltinData dat

So it seems that I fill up txData and set up datum hash properly.
But when I use it in the code datum can only be found if it is the same as used in the inputs. If I change the datum validator can not find it in the outputs of TxInfo by hash although datum hash is present.
I tried to lookup how the function toCardanoTxBody works and I can see that it does not use txData.
Or maybe I miss something?
Please can you explain how txData should be used in the Cardano TxBody properly so that I can continue with my testing?
or how it should be used in toCardanoTxBody?

As I understand Cardano Tx does not contain datum's and only hashes are used.
How can the datums be visible to evaluateTransactionExecutionUnits?

I've tried to include also output datums in the UTxO argument of evaluateTransactionExecutionUnits and it also can not find them :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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