IntersectMBO / IntersectMBO/cardano-cli

build-raw does not compute script_data_hash when using reference scripts

Open
#1,363 1 comment 0 reactions 0 assignees View on GitHub
Stale
Dominant language
Haskell
Stars
71
Forks
24
Avg merge
23h 40m
Merged PRs (30d)
14

Description

## Description

`cardano-cli latest transaction build-raw` accepts `--spending-tx-in-reference` and related flags for spending via Plutus reference scripts, but does not compute the `script_data_hash` ([field 11 in the Conway CDDL](https://github.com/IntersectMBO/cardano-ledger/blob/0cf935ca78d9c5288f99a53d9d67123e4f7d7d70/eras/conway/impl/cddl-files/conway.cddl#L140)). The ledger requires this field when Plutus scripts are involved, so the resulting transaction body is invalid on-chain.

## Steps to reproduce

1. Build a transaction with `build-raw` that spends a UTxO locked by a Plutus V3 reference script:
```
cardano-cli latest transaction build-raw \
--tx-in \
--spending-tx-in-reference \
--spending-plutus-script-v3 \
--spending-reference-tx-in-redeemer-file redeemer.json \
--spending-reference-tx-in-execution-units "(600000000,1800000)" \
...
```
2. Attempt to sign and submit the resulting transaction.
3. Submission fails because `script_data_hash` is missing from the transaction body.

## Expected behaviour

`build-raw` should compute and include the `script_data_hash` in the transaction body when redeemers are present, similar to how `transaction build` handles this.

## Current workaround

Users are forced to compute the hash externally and patch the CBOR of the transaction body after the fact.

## Context

This was reported by a user building chained transactions (where `build` cannot be used because intermediate UTxOs don't exist on-chain yet, and `build-estimate` doesn't balance native assets).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.