An output Datum.


  • NoDatum
  • DatumHash(Hash<Blake2b_256, Data>)

    A datum referenced by its hash digest.

  • InlineDatum(Data)

    A datum completely inlined in the output.

An Input made of an output reference and, the resolved value associated with that output.


  • Input { output_reference: OutputReference, output: Output }

A transaction Output, with an address, a value and optional datums and script references.


  • Output {
      address: Address,
      value: Value,
      datum: Datum,
      reference_script: Option<Hash<Blake2b_224, Script>>,

An OutputReference is a unique reference to an output on-chain. The output_index corresponds to the position in the output list of the transaction (identified by its id) that produced that output


  • OutputReference { transaction_id: TransactionId, output_index: Int }

A type-alias for Redeemers, passed to scripts for validation. The Data is opaque because it is user-defined and it is the script’s responsibility to parse it into its expected form.


Redeemer = Data

A context given to a script by the Cardano ledger when being executed.

The context contains information about the entire transaction that contains the script. The transaction may also contain other scripts; to distinguish between multiple scripts, the ScriptContext also contains a purpose which indicates which script (or, for what purpose) of the transaction is being executed.


  • ScriptContext { transaction: Transaction, purpose: ScriptPurpose }

Characterizes the kind of script being executed.


  • Mint(PolicyId)

    For scripts executed as minting/burning policies, to insert or remove assets from circulation. It’s parameterized by the identifier of the associated policy.

  • Spend(OutputReference)

    For scripts that are used as payment credentials for addresses in transaction outputs. They govern the rule by which the output they reference can be spent.

  • WithdrawFrom(StakeCredential)

    For scripts that validate reward withdrawals from a reward account.

    The argument identifies the target reward account.

  • Publish(Certificate)

    Needed when delegating to a pool using stake credentials defined as a Plutus script. This purpose is also triggered when de-registering such stake credentials.

    It embeds the certificate that’s being validated.

A Cardano Transaction, as seen by Plutus scripts.

Note that this is a representation of a transaction, and not the 1:1 translation of the transaction as seen by the ledger. In particular, Plutus scripts can’t see inputs locked by bootstrap addresses, outputs to bootstrap addresses or just transaction metadata.


  • Transaction {
      inputs: List<Input>,
      reference_inputs: List<Input>,
      outputs: List<Output>,
      fee: Value,
      mint: MintedValue,
      certificates: List<Certificate>,
      withdrawals: Dict<StakeCredential, Int>,
      validity_range: ValidityRange,
      extra_signatories: List<Hash<Blake2b_224, VerificationKey>>,
      redeemers: Dict<ScriptPurpose, Redeemer>,
      datums: Dict<Hash<Blake2b_256, Data>, Data>,
      id: TransactionId,

A unique transaction identifier, as the hash of a transaction body. Note that the transaction id isn’t a direct hash of the Transaction as visible on-chain. Rather, they correspond to hash digests of transaction body as they are serialized on the network.


  • TransactionId { hash: Hash<Blake2b_256, Transaction> }

An interval of POSIX time, measured in number milliseconds since 1970-01-01T00:00:00Z.


ValidityRange = Interval<PosixTime>


  outputs: List<Output>,
  datums: Dict<Hash<Blake2b_256, Data>, Data>,
  datum_hash: Hash<Blake2b_256, Data>,
) -> Option<Data>

Find a Datum by its hash, if present. The function looks first for datums in the witness set, and then for inline datums if it doesn’t find any in witnesses.

  inputs: List<Input>,
  output_reference: OutputReference,
) -> Option<Input>

Find an input by its OutputReference. This is typically used in combination with the Spend ScriptPurpose to find a script’s own input.

validator {
  fn(datum, redeemer, ctx: ScriptContext) {
    expect Spend(my_output_reference) =

    expect Some(input) =
        |> transaction.find_input(my_output_reference)

  outputs: List<Output>,
  script_hash: Hash<Blake2b_224, Script>,
) -> List<Output>

Find all outputs that are paying into the given script hash, if any. This is useful for contracts running over multiple transactions.

placeholder() -> Transaction

A placeholder / empty Transaction to serve as a base in a transaction builder. This is particularly useful for constructing test transactions.

Every field is empty or null, and we have in particular:

use aiken/transaction

transaction.placeholder().id == TransactionId {
  hash: #"0000000000000000000000000000000000000000000000000000000000000000",

transaction.placeholder().validity_range == interval.everything()
Search Document