Skip to content
Open
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions CIP-0172/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
CIP: 172
Title: Self-Usable Transaction Outputs
Status: Proposed
Category: Ledger
Authors:
- Carlos Tomé Cortiñas <carlos.tome-cortinas@iohk.io>
Implementors:
Discussions:
Created: 2026-01-15
License: CC-BY-4.0
---

## Abstract

We propose to allow transactions to reference scripts and data present on their
own outputs during validation.

## Motivation: Why is this CIP necessary?

Transaction outputs carry scripts (via reference scripts) and/or data (via
inline datum). However, the Cardano Ledger currently enforces a restriction
Comment thread
carlostome marked this conversation as resolved.
Outdated
that prevents a transaction from satisfying its validation requirements using
scripts and data contained within its own outputs.
Comment thread
carlostome marked this conversation as resolved.
Outdated

This restriction creates a specific inefficiency: if a transaction produces an
output containing a script or datum that is also required to validate that same
transaction, the transaction cannot utilize the copy present in the output.
Instead, the transaction must provide a redundant copy of the same script or
data (e.g., in the transaction witnesses). This forced redundancy increases
Comment thread
carlostome marked this conversation as resolved.
Outdated
transaction size, and thus transaction fees, directly inflating the costs
incurred by users.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow the argument of re-using inlined data.

If a transaction wants to spend an output that carries inlined data, that data would already be in the utxo set and thus the creating tx paid for it. For "normal" datum use, there would only be a datumhash on the utxo and the spending transaction provides the preimage in the witness set. This data resolves across any spent inputs that are parameterized by the same data (hash). I don't know how this evolves for nested transactions but I would expect it to allow re-use of hashed data. For other validation purposes, there is no datum in the context.

So, what exactly motivates the sketched change of getDatum in the agda spec?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree with this point, since datums are not reusable from reference inputs either. This change alone would lead to strange semantic where datum from outputs created can be reused throughout a transaction, while ones specified in inputs and reference inputs cannot. If we are to make such a change it would require its own CIP. However, I vaguely remember discussing this point long time ago with some folks that actually write DApps and their argument against was that it is very rare that a script requires the same data and it is usually fairly small anyways.
I think it would be worthwhile analyzing the chain and see whether there could actually be some space savings if we were to add such feature of inline datums being shared throughout a transaction.


In combination with the upcoming feature of [nested transactions](https://github.com/cardano-foundation/CIPs/blob/master/CIP-0118/README.md), in the
Dijkstra era, the current restriction imposes a strict constraint in how
scripts and/or data can be shared within a batch. Specifically, without this
Comment thread
carlostome marked this conversation as resolved.
Outdated
proposal, scripts and/or data produced in transaction outputs are only
Comment thread
carlostome marked this conversation as resolved.
Outdated
accessible to subsequent sub-transactions (via reference inputs). This forces
transaction builders to artificially order transactions or to provide redundant
copies of the same script or data (e.g., if two sub-transactions mutually
Comment thread
carlostome marked this conversation as resolved.
Outdated
depend on each other's script and/or data).
Comment thread
carlostome marked this conversation as resolved.
Outdated

The key idea of this CIP is to remove this restriction, allowing transactions
Comment thread
rphair marked this conversation as resolved.
to reference their own outputs for validation purposes.

### Use cases

#### Combine publishing reference scripts with first usage

Currently deploying stateful dApps on Cardano requires a multi-transaction
workflow:
- First transaction: Deploy the dApp's script as a reference script in the
UTxO.
- Second transaction: Reference this script (via reference inputs) to mint
state tokens.

(Note that this can be achieved swapping the order of transactions. However, it
still requires two transactions)

With the proposed changes, such applications could be deployed in a single
transaction, which simultaneously deploys the reference script UTxO's and mints
the state token. This eliminates the need for submitting multiple transactions,
thereby reducing costs, while at the same time improving the developer's
experience.

#### Nested transactions: order-agnostic script sharing across a batch

The nested transactions CIP specifies that scripts are to be shared among all
sub- and top-level transactions within a batch (see [CIP-0118 > Changes to Transaction
Validity](https://github.com/carlostome/CIPs/tree/master/CIP-0118#changes-to-transaction-validity)).

With the current restriction, this requirement can only be partially achieved
by sharing scripts either (1) from transaction witnesses or (2) via reference
inputs that point to outputs of sub-transactions in the same batch which have
already been applied to the UTxO state.

With the proposed change in this CIP, the requirement can be achieved allowing
scripts to be shared directly from transaction outputs, regardless of which
sub- or top-level transaction they appear in. This eliminates the dependency on
processing order and enables more flexible script sharing within the batch.
Comment thread
rphair marked this conversation as resolved.

## Specification

There is an [Agda
specification](https://github.com/IntersectMBO/formal-ledger-specifications/tree/carlos/usable-outputs)
prototype of the proposed changes (for Conway).

### Changes to the Ledger logic

- The function `txscripts` needs to be modified to include scripts from `txouts`.
- The function `getDatum` needs to be modified to include data from `txouts`.
Comment thread
rphair marked this conversation as resolved.
Outdated

## Rationale: How does this CIP achieve its goals?

The current ledger logic prohibits transactions from accessing their own
outputs during validation. However, this restriction comes at the cost of
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording isn't accurate. Ledger doesn't prohibit anything and there really isn't such a concept of transaction accessing anything. Also it kinda contradicts the fact that outputs are available in plutus context
If I understand correctly what you are trying to say I would suggest instead something like this:

Suggested change
The current ledger logic prohibits transactions from accessing their own
outputs during validation. However, this restriction comes at the cost of
The current logic in Ledger rules does not utilize reference scripts present in the outputs in any way. This restriction comes at the cost of

redundancy when the same script or datum serves dual purposes: being included
in an output for future use and being required for current validation.

This CIP achieves its goal by relaxing this restriction so that validation may
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This CIP achieves its goal by relaxing this restriction so that validation may
This CIP achieves its goal by enhancing Ledger rules so that validation may

reference scripts and data committed in the transaction body’s outputs, which
Comment thread
carlostome marked this conversation as resolved.
Outdated
removes the need to carry duplicate copies in witnesses and reduces transaction
size and fees.

Comment thread
rphair marked this conversation as resolved.
### Backward compatibility

The changes proposed in this CIP break backward compatibility of Plutus scripts
whose logic depends on the script being part of the outputs of the transaction
being validated.
Comment thread
carlostome marked this conversation as resolved.
Outdated

## Path to Active

### Acceptance Criteria

- Fully implemented in Cardano node

### Implementation Plan

- TODO
Comment on lines +111 to +117
Copy link
Copy Markdown
Collaborator

@rphair rphair Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Acceptance Criteria
- Fully implemented in Cardano node
### Implementation Plan
- TODO
### Acceptance Criteria
- [ ] Fully implemented in Cardano node
### Implementation Plan
- [ ] Update the formal Ledger specification with "changes to the Ledger logic" above
- [ ] Implement the outlined changes in the Cardano node
- [ ] Complete a hard fork enabling support for the changes outlined here

I used https://github.com/carlostome/CIPs/tree/master/CIP-0118#implementation-plan as a template:

  1. @Ryun1 @lehins can please double check for consistency with similar Ledger proposals?
  2. @carlostome & others please add anything in developer relations that could be seen as a dependency (a common issue with Ledger changes so perhaps implicit & therefore no need to publicise it?)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p.s. I can also see (somehow missed before) in the original comment the current uncertainty about implementation in Conway vs. Dijkstra... understandably this would still be TODO while that decision is made.


## Copyright

This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode).