IntersectMBO / cardano-api

Cardano API
Apache License 2.0
22 stars 20 forks source link

[FR] - Capability to add additional data in a body content #600

Open mmontin opened 1 month ago

mmontin commented 1 month ago

Internal/External External

Area Plutus

Describe the feature you'd like

At the moment, it does not seem possible to pass additional data in the form of a correspondance between a datum hash and a datum in a transaction body, in addition to the one collected from the script witnesses in inputs, and the outputs of the body.

However, when referencing a utxo which happens to have a hashed datum, this is needed.

Indeed, in function mkShelleyTransactionBody we can see that the HashableScriptData are derived from the body itself, from the two locations mentioned above, as follows:

    scriptdata :: [HashableScriptData]
    scriptdata =
      [d | TxOut _ _ (TxOutDatumInTx _ d) _ <- txOuts]
        ++ [ d
           | ( _
              , AnyScriptWitness
                  ( PlutusScriptWitness
                      _
                      _
                      _
                      (ScriptDatumForTxIn (Just d))
                      _
                      _
                    )
              ) <-
              witnesses
           ]

Then, the verification hash of the body is computed from these data using convPParamsToScriptIntegrityHash, and is wrapped as well in the Shelley transaction body. As a consequence, there seem to be no builtin way to have additional data in the resulting Shelley transaction body.

My feature request is to have such a way of including additional data in the transaction body.

This could take several forms, such as:

Describe alternatives you've considered

For now, I have used the following work-around:

This does allow the ledger to generate the proper script context but it does not feel like the proper way to achieve this result.

smelc commented 1 month ago

cc @Jimbo4350 @carbolymer

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

mmontin commented 2 days ago

Following a discussion I had on Discord, it was confirmed that this feature is not currently present. I will work on a contribution to integrate it.