net.corda.core.contracts

## Class TransactionForContract

- net.corda.core.contracts.TransactionForContract

-     public class TransactionForContract

  A transaction to be passed as input to a contract verification function. Defines helper methods to simplify verification logic in contracts.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `TransactionForContract.InOutGroup<T extends ContractState,K>` A set of related inputs and outputs that are connected by some common attributes. An InOutGroup is calculated using groupStates and is useful for handling cases where a transaction may contain similar but unrelated state evolutions, for example, a transaction that moves cash in two different currencies. The numbers must add up on both sides of the transaction, but the values must be summed independently per currency. Grouping can be used to simplify this logic.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TransactionForContract(java.util.List<? extends net.corda.core.contracts.ContractState> inputs, java.util.List<? extends net.corda.core.contracts.ContractState> outputs, java.util.List<? extends net.corda.core.contracts.Attachment> attachments, java.util.List<? extends net.corda.core.contracts.AuthenticatedObject<? extends net.corda.core.contracts.CommandData>> commands, SecureHash origHash, Party inputNotary, Timestamp timestamp)` A transaction to be passed as input to a contract verification function. Defines helper methods to simplify verification logic in contracts.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.List<net.corda.core.contracts.ContractState>` | `component1()`
    `java.util.List<net.corda.core.contracts.ContractState>` | `component2()`
    `java.util.List<net.corda.core.contracts.Attachment>` | `component3()`
    `java.util.List<net.corda.core.contracts.AuthenticatedObject>` | `component4()`
    `SecureHash` | `component5()`
    `Party` | `component6()`
    `Timestamp` | `component7()`
    `TransactionForContract` | `copy(java.util.List<? extends net.corda.core.contracts.ContractState> inputs, java.util.List<? extends net.corda.core.contracts.ContractState> outputs, java.util.List<? extends net.corda.core.contracts.Attachment> attachments, java.util.List<? extends net.corda.core.contracts.AuthenticatedObject<? extends net.corda.core.contracts.CommandData>> commands, SecureHash origHash, Party inputNotary, Timestamp timestamp)` A transaction to be passed as input to a contract verification function. Defines helper methods to simplify verification logic in contracts.
    `boolean` | `equals(java.lang.Object other)`
    `java.util.List<net.corda.core.contracts.Attachment>` | `getAttachments()`
    `java.util.List<net.corda.core.contracts.AuthenticatedObject>` | `getCommands()`
    `Party` | `getInputNotary()`
    `java.util.List<net.corda.core.contracts.ContractState>` | `getInputs()`
    `SecureHash` | `getOrigHash()`
    `java.util.List<net.corda.core.contracts.ContractState>` | `getOutputs()`
    `Timestamp` | `getTimestamp()`
    `<T extends ContractState,K> java.util.List<net.corda.core.contracts.TransactionForContract.InOutGroup>` | `groupStates(java.lang.Class<T> ofType, kotlin.jvm.functions.Function1<? super T,? extends K> selector)` Given a type and a function that returns a grouping key, associates inputs and outputs together so that they can be processed as one. The grouping key is any arbitrary object that can act as a map key (so must implement equals and hashCode).
    `<T extends ContractState,K> java.util.List<net.corda.core.contracts.TransactionForContract.InOutGroup>` | `groupStatesInternal(java.util.Map<K,? extends java.util.List<? extends T>> inGroups, java.util.Map<K,? extends java.util.List<? extends T>> outGroups)` Deprecated.
    `int` | `hashCode()`
    `java.lang.String` | `toString()`

- - ### Constructor Detail

    - #### TransactionForContract

          public TransactionForContract(java.util.List<? extends net.corda.core.contracts.ContractState> inputs,
                                        java.util.List<? extends net.corda.core.contracts.ContractState> outputs,
                                        java.util.List<? extends net.corda.core.contracts.Attachment> attachments,
                                        java.util.List<? extends net.corda.core.contracts.AuthenticatedObject<? extends net.corda.core.contracts.CommandData>> commands,
                                        SecureHash origHash,
                                        Party inputNotary,
                                        Timestamp timestamp)

      A transaction to be passed as input to a contract verification function. Defines helper methods to simplify verification logic in contracts.

  - ### Method Detail

    - #### hashCode

          public int hashCode()

    - #### equals

          public boolean equals(java.lang.Object other)

    - #### groupStates

          public <T extends ContractState,K> java.util.List<net.corda.core.contracts.TransactionForContract.InOutGroup> groupStates(java.lang.Class<T> ofType,
                                                                                                                                    kotlin.jvm.functions.Function1<? super T,? extends K> selector)

      Given a type and a function that returns a grouping key, associates inputs and outputs together so that they can be processed as one. The grouping key is any arbitrary object that can act as a map key (so must implement equals and hashCode).

      The purpose of this function is to simplify the writing of verification logic for transactions that may contain similar but unrelated state evolutions which need to be checked independently. Consider a transaction that simultaneously moves both dollars and euros (e.g. is an atomic FX trade). There may be multiple dollar inputs and multiple dollar outputs, depending on things like how fragmented the owner's vault is and whether various privacy techniques are in use. The quantity of dollars on the output side must sum to the same as on the input side, to ensure no money is being lost track of. This summation and checking must be repeated independently for each currency. To solve this, you would use groupStates with a type of Cash.State and a selector that returns the currency field: the resulting list can then be iterated over to perform the per-currency calculation.

    - #### groupStatesInternal

          public <T extends ContractState,K> java.util.List<net.corda.core.contracts.TransactionForContract.InOutGroup> groupStatesInternal(java.util.Map<K,? extends java.util.List<? extends T>> inGroups,
                                                                                                                                            java.util.Map<K,? extends java.util.List<? extends T>> outGroups)

      Deprecated.

    - #### getInputs

          public java.util.List<net.corda.core.contracts.ContractState> getInputs()

    - #### getOutputs

          public java.util.List<net.corda.core.contracts.ContractState> getOutputs()

    - #### getAttachments

          public java.util.List<net.corda.core.contracts.Attachment> getAttachments()

    - #### getCommands

          public java.util.List<net.corda.core.contracts.AuthenticatedObject> getCommands()

    - #### getOrigHash

          public SecureHash getOrigHash()

    - #### getInputNotary

          public Party getInputNotary()

    - #### getTimestamp

          public Timestamp getTimestamp()

    - #### component1

          public java.util.List<net.corda.core.contracts.ContractState> component1()

    - #### component2

          public java.util.List<net.corda.core.contracts.ContractState> component2()

    - #### component3

          public java.util.List<net.corda.core.contracts.Attachment> component3()

    - #### component4

          public java.util.List<net.corda.core.contracts.AuthenticatedObject> component4()

    - #### component5

          public SecureHash component5()

    - #### component6

          public Party component6()

    - #### component7

          public Timestamp component7()

    - #### copy

          public TransactionForContract copy(java.util.List<? extends net.corda.core.contracts.ContractState> inputs,
                                             java.util.List<? extends net.corda.core.contracts.ContractState> outputs,
                                             java.util.List<? extends net.corda.core.contracts.Attachment> attachments,
                                             java.util.List<? extends net.corda.core.contracts.AuthenticatedObject<? extends net.corda.core.contracts.CommandData>> commands,
                                             SecureHash origHash,
                                             Party inputNotary,
                                             Timestamp timestamp)

      A transaction to be passed as input to a contract verification function. Defines helper methods to simplify verification logic in contracts.

    - #### toString

          public java.lang.String toString()