aiken/transaction
Types
An output Datum.
Constructors
- 
          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.
Constructors
- 
          Input { output_reference: OutputReference, output: Output }
A transaction Output, with an address, a value and optional datums and script references.
Constructors
- 
          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
Constructors
- 
          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.
Alias
Redeemer = DataA 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.
Constructors
- 
          ScriptContext { transaction: Transaction, purpose: ScriptPurpose }
Characterizes the kind of script being executed.
Constructors
- 
          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.
Constructors
- 
          Transaction { inputs: List<Input>, reference_inputs: List<Input>, outputs: List<Output>, fee: Value, mint: MintedValue, certificates: List<Certificate>, withdrawals: Pairs<StakeCredential, Int>, validity_range: ValidityRange, extra_signatories: List<Hash<Blake2b_224, VerificationKey>>, redeemers: Pairs<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.
Constructors
- 
          TransactionId { hash: Hash<Blake2b_256, Transaction> }
An interval of POSIX time, measured in number milliseconds since 1970-01-01T00:00:00Z.
Alias
ValidityRange = Interval<PosixTime>Functions
find_datum(
  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.
find_input(
  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) =
      ctx.purpose
    expect Some(input) =
      ctx.transaction.inputs
        |> transaction.find_input(my_output_reference)
  }
}
find_script_outputs(
  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()