Detect a stale Cardano reference input before submission

A transaction can read an oracle output without consuming it. The output must still exist when the ledger validates the transaction, even if several readers used it successfully earlier.

Test the exact output reference

Resolve oracleTx#2 in the current UTxO set on the intended network. Inspect its address, assets and datum as required by the application. Keep it in the reference-input set while balancing the transaction from normal spending inputs.

spending inputs:  txA#0
reference inputs: oracleTx#2

If the oracle publisher consumes oracleTx#2 to create oracleNext#0, a prebuilt transaction still points to the spent output. Rebuild against the new reference and reevaluate the application value and script conditions.

Re-sign after changing the reference

Reference inputs are part of the transaction body. Substituting the newer output changes the body hash and invalidates signatures over the old body. A reference input’s value also cannot fund fees or outputs because it remains unspent on success. cips.cardano.org Cardano CIP-31