Transaction Inputs & Outputs (Cardano)

In Cardano, transaction inputs and outputs are key components of the UTxO (Unspent Transaction Output) model, which is used to manage how value (such as ADA) is transferred across the blockchain. Let’s break down what they mean and how they work.

Transaction Inputs

  • Definition: A transaction input is a reference to a UTxO that you want to spend in a new transaction. It points to an existing UTxO (which was an output of a previous transaction) and tells the blockchain that you’re using that UTxO to fund your new transaction.
  • How It Works: Each UTxO in your wallet is like a “coin” or “chunk” of value. When you make a transaction, you spend one or more of these UTxOs as inputs. Each input represents an entire UTxO that is being used up, whether you spend all of it or only part of it.For example, if you have a UTxO worth 5 ADA, and you want to send 3 ADA, the entire 5 ADA is used as an input in the transaction, even though you’re only sending 3 ADA (with the leftover amount returned as change).

Transaction Outputs

  • Definition: A transaction output is a new UTxO that gets created as a result of the transaction. It specifies where the value is going (e.g., to another wallet) and how much value is being transferred.
  • How It Works: Every transaction produces at least one or more outputs. The outputs are new UTxOs that become spendable in future transactions. In most cases, outputs include the amount you’re sending to a recipient and any “change” that gets sent back to you.For example, in a transaction where you send 3 ADA, there will be:
    • An output to the recipient’s wallet with 3 ADA.
    • A second output (change) sent back to your wallet if your input UTxO was larger than 3 ADA.

Inputs and Outputs in Action

  • Inputs: These are existing UTxOs from previous transactions that you’re using to fund a new transaction.
  • Outputs: These are new UTxOs created from the transaction, either going to the recipient or as “change” back to your wallet.

Example Transaction

Imagine your wallet has two UTxOs:

  • UTxO1: 6 ADA
  • UTxO2: 3 ADA

You want to send 5 ADA to a friend. Your wallet selects UTxO1 (6 ADA) as the input.

  • Inputs: UTxO1 (6 ADA).
  • Outputs:
    • Output1: 5 ADA to your friend’s wallet.
    • Output2 (Change): 1 ADA returned to your wallet as a new UTxO.

After the transaction:

  • UTxO1 is fully spent (used as an input and no longer available).
  • Your friend has 5 ADA (Output1).
  • You receive 1 ADA as change (Output2), which is a new UTxO that can be spent in future transactions.

Why Inputs and Outputs Matter

  • Traceability: Every input is linked to a previous output, meaning that every transaction can be traced back through the blockchain. This ensures transparency and prevents double-spending.
  • Efficiency: By using UTxOs, the system can easily combine or split inputs and outputs to make transactions more efficient and secure.
  • Security: Each transaction input must be fully verified by the network, ensuring that no one can spend the same output twice (double-spending is prevented).

Summary

  • Transaction Inputs: These are references to UTxOs that are being spent in a new transaction.
  • Transaction Outputs: These are new UTxOs created as a result of the transaction, representing where the value is going (to a recipient or as change).

Cardano’s UTxO model allows for clear and secure management of assets, ensuring that every unit of ADA is accounted for in the blockchain.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *