corda / net.corda.core.contracts

## Package net.corda.core.contracts

### Types

AccrualAdjustment | `enum class AccrualAdjustment` Simple enum for returning accurals adjusted or unadjusted. We don't actually do anything with this yet though, so it's ignored for now.
Amount | `data class Amount<T> : Comparable<Amount<T>>` Amount represents a positive quantity of some token (currency, asset, etc.), measured in quantity of the smallest representable units. Note that quantity is not necessarily 1/100ths of a currency unit, but are the actual smallest amount used in whatever underlying thing the amount represents.
Attachment | `interface Attachment : NamedByHash` 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:
AuthenticatedObject | `data class AuthenticatedObject<out T : Any>` Wraps an object that was signed by a public key, which may be a well known/recognised institutional key.
BilateralNettableState | `interface BilateralNettableState<N : BilateralNettableState<N>>` Interface for state objects that support being netted with other state objects.
BusinessCalendar | `open class BusinessCalendar` A business calendar performs date calculations that take into account national holidays and weekends. This is a typical feature of financial contracts, in which a business may not want a payment event to fall on a day when no staff are around to handle problems.
Command | `data class Command` Command data/content plus pubkey pair: the signature is stored at the end of the serialized bytes
CommandData | `interface CommandData` Marker interface for classes that represent commands
Commodity | `data class Commodity` Class representing a commodity, as an equivalent to the Currency class. This exists purely to enable the CommodityContract contract, and is likely to change in future.
Contract | `interface Contract` Implemented by a program that implements business logic on the shared ledger. All participants run this code for every 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 timestamp attached to the transaction itself i.e. it is NOT necessarily the current time.
ContractState | `interface 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.
DateRollConvention | `enum class DateRollConvention` This reflects what happens if a date on which a business event is supposed to happen actually falls upon a non-working day. Depending on the accounting requirement, we can move forward until we get to a business day, or backwards. There are some additional rules which are explained in the individual cases below.
DateRollDirection | `enum class DateRollDirection` This is utilised in the DateRollConvention class to determine which way we should initially step when finding a business day.
DayCountBasisDay | `enum class DayCountBasisDay` This forms the day part of the "Day Count Basis" used for interest calculation. Note that the first character cannot be a number (enum naming constraints), so we drop that in the toString lest some people get confused.
DayCountBasisYear | `enum class DayCountBasisYear` This forms the year part of the "Day Count Basis" used for interest calculation.
DealState | `interface DealState : LinearState` Interface representing an agreement that exposes various attributes that are common. Implementing it simplifies implementation of general flows that manipulate many agreement types.
DummyContract | `data class DummyContract : Contract`
DummyContractV2 | `class DummyContractV2 : UpgradedContract<State, State>` Dummy contract state for testing of the upgrade process.
DummyState | `data class DummyState : ContractState` Dummy state for use in testing. Not part of any contract, not even the DummyContract.
Expression | `data class Expression` Represents a textual expression of e.g. a formula
ExpressionDeserializer | `object ExpressionDeserializer : JsonDeserializer<Expression>`
ExpressionSerializer | `object ExpressionSerializer : JsonSerializer<Expression>`
Fix | `data class Fix : CommandData` A Fix represents a named interest rate, on a given day, for a given duration. It can be embedded in a tx.
FixOf | `data class FixOf` A FixOf identifies the question side of a fix: what day, tenor and type of fix ("LIBOR", "EURIBOR" etc)
FixableDealState | `interface FixableDealState : DealState` Interface adding fixing specific methods.
Frequency | `enum class Frequency` Frequency at which an event occurs - the enumerator also casts to an integer specifying the number of times per year that would divide into (eg annually = 1, semiannual = 2, monthly = 12 etc).
FungibleAsset | `interface FungibleAsset<T> : OwnableState` 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.
IssuanceDefinition | `interface IssuanceDefinition` Marker interface for data classes that represent the issuance state for a contract. These are intended as templates from which the state object is initialised.
IssueCommand | `interface IssueCommand : CommandData` A common issue command, to enforce that issue commands have a nonce value.
Issued | `data class Issued<out P>` Definition for an issued product, which can be cash, a cash-like thing, assets, or generally anything else that's quantifiable with integer quantities.
LinearState | `interface LinearState : ContractState` A state that evolves by superseding itself, all of which share the common "linearId".
MoveCommand | `interface MoveCommand : CommandData` A common move command for contract states which can change owner.
MultilateralNettableState | `interface MultilateralNettableState<out T : Any>` Interface for state objects that support being netted with other state objects.
NamedByHash | `interface NamedByHash` Implemented by anything that can be named by a secure hash value (e.g. transactions, attachments).
NetCommand | `interface NetCommand : CommandData` A common netting command for contracts whose states can be netted.
NetType | `enum class NetType` Enum for the types of netting that can be applied to state objects. Exact behaviour for each type of netting is left to the contract to determine.
NettableState | `interface NettableState<N : BilateralNettableState<N>, T : Any> : BilateralNettableState<N>, MultilateralNettableState<T>`
OwnableState | `interface OwnableState : ContractState` A contract state that can have a single owner.
PartyAndReference | `data class 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.
PaymentRule | `enum class PaymentRule` Whether the payment should be made before the due date, or after it.
Requirements | `object Requirements`
SchedulableState | `interface SchedulableState : ContractState`
Scheduled | `interface Scheduled` Something which is scheduled to happen at a point in time
ScheduledActivity | `data class ScheduledActivity : Scheduled` This class represents the lifecycle activity that a contract state of type LinearState would like to perform at a given point in time. e.g. run a fixing flow.
ScheduledStateRef | `data class ScheduledStateRef : Scheduled` Represents a contract state (unconsumed output) of type LinearState and a point in time that a lifecycle event is expected to take place for that contract state.
StateAndRef | `data class StateAndRef<out T : ContractState>` A StateAndRef is simply a (state, ref) pair. For instance, a vault (which holds available assets) contains these.
StateRef | `data class 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.
Tenor | `data class Tenor` Placeholder class for the Tenor datatype - which is a standardised duration of time until maturity
Timestamp | `data class Timestamp` If present in a transaction, contains a time that was verified by the uniqueness service. The true time must be between (after, before).
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.
TransactionGraphSearch | `class TransactionGraphSearch : Callable<List<WireTransaction>>` Given a map of transaction id to SignedTransaction, performs a breadth first search of the dependency graph from the starting point down in order to find transactions that match the given query criteria.
TransactionState | `data class TransactionState<out T : ContractState>` A wrapper for ContractState containing additional platform-level state information. This is the definitive state that is stored on the ledger and used in transaction outputs.
TransactionType | `sealed class TransactionType` Defines transaction build & validation logic for a specific transaction type
TypeOnlyCommandData | `abstract class TypeOnlyCommandData : CommandData` Commands that inherit from this are intended to have no data items: it's only their presence that matters.
UniqueIdentifier | `data class UniqueIdentifier : Comparable<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.
UpgradeCommand | `data class UpgradeCommand : CommandData` Indicates that this transaction replaces the inputs contract state to another contract state
UpgradedContract | `interface UpgradedContract<in OldState : ContractState, out NewState : ContractState> : Contract` Interface which can upgrade state objects issued by a contract to a new state object issued by a different contract.

### Exceptions

AttachmentResolutionException | `class AttachmentResolutionException : FlowException`
InsufficientBalanceException | `class InsufficientBalanceException : FlowException`
TransactionConflictException | `class TransactionConflictException : Exception`
TransactionResolutionException | `class TransactionResolutionException : FlowException`
TransactionVerificationException | `sealed class TransactionVerificationException : FlowException`

### Extensions for External Classes

java.time.LocalDate |
java.util.Currency |
kotlin.Double |
kotlin.Int |
kotlin.collections.Collection |
kotlin.collections.Iterable |

### Properties

CHF | `val CHF: Currency`
DUMMY_PROGRAM_ID | `val DUMMY_PROGRAM_ID: DummyContract`
DUMMY_V2_PROGRAM_ID | `val DUMMY_V2_PROGRAM_ID: DummyContractV2`
EUR | `val EUR: Currency`
FCOJ | `val FCOJ: Commodity`
GBP | `val GBP: Currency`
USD | `val USD: Currency`

### Functions

DOLLARS | `fun DOLLARS(amount: Int): Amount<Currency>` `fun DOLLARS(amount: Double): Amount<Currency>`
FCOJ | `fun FCOJ(amount: Int): Amount<Commodity>`
POUNDS | `fun POUNDS(amount: Int): Amount<Currency>`
SWISS_FRANCS | `fun SWISS_FRANCS(amount: Int): Amount<Currency>`
calculateDaysBetween | `fun calculateDaysBetween(startDate: LocalDate, endDate: LocalDate, dcbYear: DayCountBasisYear, dcbDay: DayCountBasisDay): Int`
commodity | `fun commodity(code: String): Commodity`
currency | `fun currency(code: String): Currency` Defines a simple domain specific language for the specification of financial contracts. Currently covers:
hash | `fun ContractState.hash(): SecureHash` Returns the SHA-256 hash of the serialised contents of this state (not cached!)
issued by | `infix fun Commodity.issued by(deposit: PartyAndReference): Issued<Commodity>` `infix fun Amount<Currency>.issued by(deposit: PartyAndReference): Amount<Issued<Currency>>`
issuedBy | `infix fun Commodity.issuedBy(deposit: PartyAndReference): Issued<Commodity>` `infix fun Amount<Currency>.issuedBy(deposit: PartyAndReference): Amount<Issued<Currency>>`
requireThat | `fun <R> requireThat(body: Requirements.() -> R): R`
toDecimal | `fun Amount<Currency>.toDecimal(): BigDecimal` Convert a currency Amount to a decimal representation. For example, with an amount with a quantity of "1234" GBP, returns "12.34".
verifyMoveCommand | `fun <T : MoveCommand> verifyMoveCommand(inputs: List<OwnableState>, tx: TransactionForContract): MoveCommand` `fun <T : MoveCommand> verifyMoveCommand(inputs: List<OwnableState>, commands: List<AuthenticatedObject<CommandData>>): MoveCommand` Simple functionality for verifying a move command. Verifies that each input has a signature from its owning key.
with notary | `infix fun <T : ContractState> T.with notary(newNotary: Party): TransactionState<T>` Wraps the ContractState in a TransactionState object
withNotary | `infix fun <T : ContractState> T.withNotary(newNotary: Party): TransactionState<T>`
withoutIssuer | `fun <T> Amount<Issued<T>>.withoutIssuer(): Amount<T>` Strips the issuer and returns an Amount of the raw token directly. This is useful when you are mixing code that cares about specific issuers with code that will accept any, or which is imposing issuer constraints via some other mechanism and the additional type safety is not wanted.