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

@LegalProseReference

# Package net.corda.core.contracts

- Interface Summary
  Interface | Description
  --- | ---
  Attachment | An attachment is a ZIP (or an optionally signed JAR) that contains one or more files. Attachments are meant to contain public static data which can be referenced from transactions and utilised from contracts. Good examples of how attachments are meant to be used include:
  AttachmentConstraint | Constrain which contract-code-containing attachment can be used with a `interface Contract`.
  CommandData | Marker interface for classes that represent commands
  Contract | Implemented by a program that implements business logic on the shared ledger. All participants run this code for every `class LedgerTransaction` they see on the network, for every input and output state. All contracts must accept the transaction for it to be accepted: failure of any aborts the entire thing. The time is taken from a trusted time-window attached to the transaction itself i.e. it is NOT necessarily the current time.
  ContractState | A contract state (or just "state") contains opaque data used by a contract program. It can be thought of as a disk file that the program can use to persist data across transactions. States are immutable: once created they are never updated, instead, any changes must generate a new successor state. States can be updated (consumed) only once: the notary is responsible for ensuring there is no "double spending" by only signing a transaction if the input states are all free.
  FungibleAsset<T> | Interface for contract states representing assets which are fungible, countable and issued by a specific party. States contain assets which are equivalent (such as cash of the same currency), so records of their existence can be merged or split as needed where the issuer is the same. For instance, dollars issued by the Fed are fungible and countable (in cents), barrels of West Texas crude are fungible and countable (oil from two small containers can be poured into one large container), shares of the same class in a specific company are fungible and countable, and so on.
  FungibleState<T> | Interface to represent things which are fungible, this means that there is an expectation that these things can be split and merged. That's the only assumption made by this interface.
  LinearState | A state that evolves by superseding itself, all of which share the common "linearId".
  MoveCommand | A common move command for contract states which can change owner.
  NamedByHash | Implemented by anything that can be named by a secure hash value (e.g. transactions, attachments).
  OwnableState | A contract state that can have a single owner.
  SchedulableState |
  Scheduled | Something which is scheduled to happen at a point in time.
  TokenizableAssetInfo | This interface is used by `class Amount` to determine the conversion ratio from indicative/displayed asset amounts in BigDecimal to fungible tokens represented by Amount objects.
  UpgradedContract<OldState extends ContractState,NewState extends ContractState> | Interface which can upgrade state objects issued by a contract to a new state object issued by a different contract. The upgraded contract should specify the legacy contract class name, and provide an upgrade function that will convert legacy contract states into states defined by this contract.
  UpgradedContractWithLegacyConstraint<OldState extends ContractState,NewState extends ContractState> | This interface allows specifying a custom legacy contract constraint for upgraded contracts. The default for `interface UpgradedContract` is `class WhitelistedByZoneAttachmentConstraint`.

- Class Summary
  Class | Description
  --- | ---
  AlwaysAcceptAttachmentConstraint | An `interface AttachmentConstraint` where `isSatisfiedBy` always returns true.
  Amount<T> | Amount represents a positive quantity of some token (currency, asset, etc.), measured in quantity of the smallest representable units. The nominal quantity represented by each individual token is equal to the displayTokenSize. The scale property of the displayTokenSize should correctly reflect the displayed decimal places and is used when rounding conversions from indicative/displayed amounts in BigDecimal to Amount occur via the `Amount.fromDecimal` method.
  AmountTransfer<T,P> | This class represents a possibly negative transfer of tokens from one vault state to another, possibly at a future date.
  AttachmentConstraintKt |
  AutomaticHashConstraint | Deprecated
  AutomaticPlaceholderConstraint | This `interface AttachmentConstraint` is a convenience class that acts as a placeholder and will be automatically resolved by the platform when set on an output state. It is the default constraint of all output states.
  Command<T extends CommandData> | Command data/content plus pubkey pair: the signature is stored at the end of the serialized bytes
  CommandAndState | Return structure for `OwnableState.withNewOwner`
  CommandWithParties<T extends CommandData> | A `class Command` where the signing parties have been looked up if they have a well known/recognised institutional key.
  ContractAttachment | An `interface Attachment` which represents a contract JAR.
  ContractsDSL |
  HashAttachmentConstraint | An `interface AttachmentConstraint` that verifies by hash. The state protected by this constraint can only be used in a transaction created with that version of the jar. And a receiving node will only accept it if a cordapp with that hash has (is) been deployed on the node.
  Issued<P> | The `class Issued` data class holds the details of an on ledger digital asset. In particular it gives the public credentials of the entity that created these digital tokens and the particular product represented.
  LinearPointer<T extends LinearState> | `class LinearPointer` allows a `interface ContractState` to "point" to another `interface LinearState` creating a "many-to-one" relationship between all the states containing the pointer to a particular `interface LinearState` and the `interface LinearState` being pointed to. Using the `class LinearPointer` is useful when one state depends on the data contained within another state that evolves independently. When using `class LinearPointer` it is worth noting:
  PartyAndReference | Reference to something being stored or issued by a party e.g. in a vault or (more likely) on their normal ledger. The reference is intended to be encrypted so it's meaningless to anyone other than the party.
  PrivacySalt | A privacy salt is required to compute nonces per transaction component in order to ensure that an adversary cannot use brute force techniques and reveal the content of a Merkle-leaf hashed value. Because this salt serves the role of the seed to compute nonces, its size and entropy should be equal to the underlying hash function used for Merkle tree generation, currently `class SecureHash.SHA256`, which has an output of 32 bytes. There are two constructors, one that generates a new 32-bytes random salt, and another that takes a ByteArray input. The latter is required in cases where the salt value needs to be pre-generated (agreed between transacting parties), but it is highlighted that one should always ensure it has sufficient entropy.
  ReferencedStateAndRef<T extends ContractState> | A wrapper for a `class StateAndRef` indicating that it should be added to a transaction as a reference input state.
  Requirements | Defines a simple domain specific language for the specification of financial contracts. Currently covers:
  ScheduledActivity | This class represents the lifecycle activity that a contract state of type `interface LinearState` would like to perform at a given point in time. e.g. run a fixing flow.
  ScheduledStateRef | Represents a contract state (unconsumed output) of type `interface LinearState` and a point in time that a lifecycle event is expected to take place for that contract state.
  SignatureAttachmentConstraint | An `interface AttachmentConstraint` that verifies that the attachment has signers that fulfil the provided PublicKey. See: Signature Constraints
  SourceAndAmount<T,P> | Simple data class to associate the origin, owner, or holder of a particular Amount object.
  StateAndContract | A convenience class for passing around a state and it's contract
  StateAndRef<T extends ContractState> | A StateAndRef is simply a (state, ref) pair. For instance, a vault (which holds available assets) contains these.
  StatePointer<T extends ContractState> | A `class StatePointer` contains a `pointer` to a `interface ContractState`. The `class StatePointer` can be included in a `interface ContractState` or included in an off-ledger data structure. `class StatePointer`s can be resolved to a `class StateAndRef` by performing a vault query. There are two types of pointers; linear and static. `class LinearPointer`s are for use with `interface LinearState`s. `class StaticPointer`s are for use with any type of `interface ContractState`.
  StateRef | A stateref is a pointer (reference) to a state, this is an equivalent of an "outpoint" in Bitcoin. It records which transaction defined the state and where in that transaction it was.
  StaticPointer<T extends ContractState> | A `class StaticPointer` contains a pointer to a specific `class StateRef` and can be resolved by looking up the `class StateRef` via `interface ServiceHub`. There are a number of things to keep in mind when using `class StaticPointer`s:
  Structures |
  TimeWindow | An interval on the time-line; not a single instantaneous point.
  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.
  TransactionStateKt |
  TypeOnlyCommandData | Commands that inherit from this are intended to have no data items: it's only their presence that matters.
  UniqueIdentifier | This class provides a truly unique identifier of a trade, state, or other business object, bound to any existing external ID. Equality and comparison are based on the unique ID only; if two states somehow have the same UUID but different external IDs, it would indicate a problem with handling of IDs.
  WhitelistedByZoneAttachmentConstraint | An `interface AttachmentConstraint` that verifies that the hash of the attachment is in the network parameters whitelist. See: net.corda.core.node.NetworkParameters.whitelistedContractImplementations It allows for centralized control over the cordapps that can be used.

- Enum Summary
  Enum | Description
  --- | ---
  ComponentGroupEnum | An enum, for which each property corresponds to a transaction component group. The position in the enum class declaration (ordinal) is used for component-leaf ordering when computing the Merkle tree.

- Exception Summary
  Exception | Description
  --- | ---
  AttachmentResolutionException | The node asked a remote peer for the attachment identified by hash because it is a dependency of a transaction being resolved, but the remote peer would not provide it.
  BrokenAttachmentException | A non-specific exception for the attachment identified by attachmentId. The context for this error is provided via the message and cause.
  InsufficientBalanceException | Thrown if a request is made to spend an amount of a `interface FungibleAsset` but there aren't enough tokens in the vault.
  TransactionResolutionException | The node asked a remote peer for the transaction identified by hash because it is a dependency of a transaction being resolved, but the remote peer would not provide it.
  TransactionVerificationException | Indicates that some aspect of the transaction named by txId violates the platform rules. The exact type of failure is expressed using a subclass. TransactionVerificationException is a `exception FlowException` and thus when thrown inside a flow, the details of the failure will be serialised, propagated to the peer and rethrown.