com.r3corda.core.contracts / TransactionForContract

# TransactionForContract

`data class TransactionForContract`

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

### Types

InOutGroup | `data class InOutGroup<out T : ContractState, out K : Any>` 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.

### Constructors

<init> | `TransactionForContract(inputs: List<ContractState>, outputs: List<ContractState>, attachments: List<Attachment>, commands: List<AuthenticatedObject<CommandData>>, origHash: SecureHash, inputNotary: Party? = null)` A transaction to be passed as input to a contract verification function. Defines helper methods to simplify verification logic in contracts.

### Properties

attachments | `val attachments: List<Attachment>`
commands | `val commands: List<AuthenticatedObject<CommandData>>`
inStates | `val inStates: List<ContractState>`
inputNotary | `val inputNotary: Party?`
inputs | `val inputs: List<ContractState>`
origHash | `val origHash: SecureHash`
outStates | `val outStates: List<ContractState>`
outputs | `val outputs: List<ContractState>`
timestamp | `val timestamp: TimestampCommand?` Get the timestamp command for this transaction, using the notary from the input states.

### Functions

equals | `fun equals(other: Any?): Boolean`
getTimestampBy | `fun getTimestampBy(timestampingAuthority: Party): TimestampCommand?` Simply calls commands.getTimestampBy as a shortcut to make code completion more intuitive.
getTimestampByName | `fun getTimestampByName(vararg authorityName: String): TimestampCommand?` Simply calls commands.getTimestampByName as a shortcut to make code completion more intuitive.
groupStates | `fun <T : ContractState, K : Any> groupStates(ofType: Class<T>, selector: (T) -> K): List<InOutGroup<T, K>>` 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). `fun <T : ContractState, K : Any> groupStates(selector: (T) -> K): List<InOutGroup<T, K>>` See the documentation for the reflection-based version of groupStates
groupStatesInternal | `fun <T : ContractState, K : Any> groupStatesInternal(inGroups: Map<K, List<T>>, outGroups: Map<K, List<T>>): List<InOutGroup<T, K>>`
hashCode | `fun hashCode(): Int`