TransactionState
Keywords: net.corda.core.contracts.TransactionState class
Date: 2023-09-18

net.corda.core.contracts

## Class TransactionState<T extends ContractState>

- net.corda.core.contracts.TransactionState<T>

-     public class TransactionState<T extends ContractState>

  A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

  See Also:
    `interface ContractState`

- - ### Field Detail

    - #### Companion

          public static net.corda.core.contracts.TransactionState.Companion Companion

      Deprecated.

  - ### Constructor Detail

    - #### TransactionState

          @JvmOverloads
          public TransactionState(@NotNull
                                                T data,
                                                @NotNull
                                                java.lang.String contract,
                                                @NotNull
                                                Party notary,
                                                @Nullable
                                                java.lang.Integer encumbrance,
                                                @NotNull
                                                AttachmentConstraint constraint)

      A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

      Parameters:
        `data` - The custom contract state
        `contract` -

        The contract class name that will verify this state that will be created via reflection. The attachment containing this class will be automatically added to the transaction at transaction creation time.

        Currently these are loaded from the classpath of the node which includes the cordapp directory - at some point these will also be loaded and run from the attachment store directly, allowing contracts to be sent across, and run, from the network from within a sandbox environment.

        `notary` - Identity of the notary that ensures the state is not used as an input to a transaction more than once
        `encumbrance` -

        All contract states may be encumbered by up to one other state.

        The encumbrance state, if present, forces additional controls over the encumbered state, since the platform checks that the encumbrance state is present as an input in the same transaction that consumes the encumbered state, and the contract code and rules of the encumbrance state will also be verified during the execution of the transaction. For example, a cash contract state could be encumbered with a time-lock contract state; the cash state is then only processable in a transaction that verifies that the time specified in the encumbrance time-lock has passed.

        The encumbered state refers to another by index, and the referred encumbrance state is an output state in a particular position on the same transaction that created the encumbered state. An alternative implementation would be encumbering by reference to a `class StateRef`, which would allow the specification of encumbrance by a state created in a prior transaction.

        Note that an encumbered state that is being consumed must have its encumbrance consumed in the same transaction, otherwise the transaction is not valid.

        `constraint` - A validator for the contract attachments on the transaction.
      See Also:
        `interface ContractState`

    - #### TransactionState

          @JvmOverloads
          public TransactionState(@NotNull
                                                T data,
                                                @NotNull
                                                java.lang.String contract,
                                                @NotNull
                                                Party notary,
                                                @Nullable
                                                java.lang.Integer encumbrance)

      A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

      Parameters:
        `data` - The custom contract state
        `contract` -

        The contract class name that will verify this state that will be created via reflection. The attachment containing this class will be automatically added to the transaction at transaction creation time.

        Currently these are loaded from the classpath of the node which includes the cordapp directory - at some point these will also be loaded and run from the attachment store directly, allowing contracts to be sent across, and run, from the network from within a sandbox environment.

        `notary` - Identity of the notary that ensures the state is not used as an input to a transaction more than once
        `encumbrance` -

        All contract states may be encumbered by up to one other state.

        The encumbrance state, if present, forces additional controls over the encumbered state, since the platform checks that the encumbrance state is present as an input in the same transaction that consumes the encumbered state, and the contract code and rules of the encumbrance state will also be verified during the execution of the transaction. For example, a cash contract state could be encumbered with a time-lock contract state; the cash state is then only processable in a transaction that verifies that the time specified in the encumbrance time-lock has passed.

        The encumbered state refers to another by index, and the referred encumbrance state is an output state in a particular position on the same transaction that created the encumbered state. An alternative implementation would be encumbering by reference to a `class StateRef`, which would allow the specification of encumbrance by a state created in a prior transaction.

        Note that an encumbered state that is being consumed must have its encumbrance consumed in the same transaction, otherwise the transaction is not valid.

      See Also:
        `interface ContractState`

    - #### TransactionState

          @JvmOverloads
          public TransactionState(@NotNull
                                                T data,
                                                @NotNull
                                                java.lang.String contract,
                                                @NotNull
                                                Party notary)

      A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

      Parameters:
        `data` - The custom contract state
        `contract` -

        The contract class name that will verify this state that will be created via reflection. The attachment containing this class will be automatically added to the transaction at transaction creation time.

        Currently these are loaded from the classpath of the node which includes the cordapp directory - at some point these will also be loaded and run from the attachment store directly, allowing contracts to be sent across, and run, from the network from within a sandbox environment.

        `notary` - Identity of the notary that ensures the state is not used as an input to a transaction more than once
      See Also:
        `interface ContractState`

    - #### TransactionState

          @JvmOverloads
          public TransactionState(@NotNull
                                                T data,
                                                @NotNull
                                                Party notary)

      A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

      Parameters:
        `data` - The custom contract state
        `notary` - Identity of the notary that ensures the state is not used as an input to a transaction more than once
      See Also:
        `interface ContractState`

  - ### Method Detail

    - #### getData

          @NotNull
          public T getData()

      The custom contract state

    - #### getContract

          @NotNull
          public java.lang.String getContract()

      The contract class name that will verify this state that will be created via reflection. The attachment containing this class will be automatically added to the transaction at transaction creation time.

      Currently these are loaded from the classpath of the node which includes the cordapp directory - at some point these will also be loaded and run from the attachment store directly, allowing contracts to be sent across, and run, from the network from within a sandbox environment.

    - #### getNotary

          @NotNull
          public Party getNotary()

      Identity of the notary that ensures the state is not used as an input to a transaction more than once

    - #### getEncumbrance

          @Nullable
          public java.lang.Integer getEncumbrance()

      All contract states may be encumbered by up to one other state.

      The encumbrance state, if present, forces additional controls over the encumbered state, since the platform checks that the encumbrance state is present as an input in the same transaction that consumes the encumbered state, and the contract code and rules of the encumbrance state will also be verified during the execution of the transaction. For example, a cash contract state could be encumbered with a time-lock contract state; the cash state is then only processable in a transaction that verifies that the time specified in the encumbrance time-lock has passed.

      The encumbered state refers to another by index, and the referred encumbrance state is an output state in a particular position on the same transaction that created the encumbered state. An alternative implementation would be encumbering by reference to a `class StateRef`, which would allow the specification of encumbrance by a state created in a prior transaction.

      Note that an encumbered state that is being consumed must have its encumbrance consumed in the same transaction, otherwise the transaction is not valid.

      See Also:
        `class StateRef`

    - #### getConstraint

          @NotNull
          public AttachmentConstraint getConstraint()

      A validator for the contract attachments on the transaction.

    - #### component1

          @NotNull
          public T component1()

      The custom contract state

    - #### component2

          @NotNull
          public java.lang.String component2()

      The contract class name that will verify this state that will be created via reflection. The attachment containing this class will be automatically added to the transaction at transaction creation time.

      Currently these are loaded from the classpath of the node which includes the cordapp directory - at some point these will also be loaded and run from the attachment store directly, allowing contracts to be sent across, and run, from the network from within a sandbox environment.

    - #### component3

          @NotNull
          public Party component3()

      Identity of the notary that ensures the state is not used as an input to a transaction more than once

    - #### component4

          @Nullable
          public java.lang.Integer component4()

      All contract states may be encumbered by up to one other state.

      The encumbrance state, if present, forces additional controls over the encumbered state, since the platform checks that the encumbrance state is present as an input in the same transaction that consumes the encumbered state, and the contract code and rules of the encumbrance state will also be verified during the execution of the transaction. For example, a cash contract state could be encumbered with a time-lock contract state; the cash state is then only processable in a transaction that verifies that the time specified in the encumbrance time-lock has passed.

      The encumbered state refers to another by index, and the referred encumbrance state is an output state in a particular position on the same transaction that created the encumbered state. An alternative implementation would be encumbering by reference to a `class StateRef`, which would allow the specification of encumbrance by a state created in a prior transaction.

      Note that an encumbered state that is being consumed must have its encumbrance consumed in the same transaction, otherwise the transaction is not valid.

      See Also:
        `class StateRef`

    - #### component5

          @NotNull
          public AttachmentConstraint component5()

      A validator for the contract attachments on the transaction.

    - #### copy

          @NotNull
          public TransactionState<T> copy(@NotNull
                                                   T data,
                                                   @NotNull
                                                   java.lang.String contract,
                                                   @NotNull
                                                   Party notary,
                                                   @Nullable
                                                   java.lang.Integer encumbrance,
                                                   @NotNull
                                                   AttachmentConstraint constraint)

      A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

      See Also:
        `interface ContractState`

    - #### toString

          @NotNull
          public java.lang.String toString()

      A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

      See Also:
        `interface ContractState`

    - #### hashCode

          public int hashCode()

      A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

      See Also:
        `interface ContractState`

    - #### equals

          public boolean equals(@Nullable
                                java.lang.Object p)

      A wrapper for `interface ContractState` containing additional platform-level state information and contract information. This is the definitive state that is stored on the ledger and used in transaction outputs.

      See Also:
        `interface ContractState`