corda / net.corda.core.contracts / Contract

Contract

interface Contract

Implemented by a program that implements business logic on the shared ledger. All participants run this code for every net.corda.core.transactions.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.

TODO: Contract serialization is likely to change, so the annotation is likely temporary.

Functions

verify

abstract fun verify(tx: LedgerTransaction): Unit

Takes an object that represents a state transition, and ensures the inputs/outputs/commands make sense. Must throw an exception if there's a problem that should prevent state transition. Takes a single object rather than an argument so that additional data can be added without breaking binary compatibility with existing contract code.

Extension Functions

contextLogger

fun Any.contextLogger(): <ERROR CLASS>

When called from a companion object, returns the logger for the enclosing class.

Inheritors

CommercialPaper

class CommercialPaper : Contract

Obligation

class Obligation<P : Any> : Contract

An obligation contract commits the obligor to delivering a specified amount of a fungible asset (for example the Cash contract) at a specified future point in time. Settlement transactions may split and merge contracts across multiple input and output states. The goal of this design is to handle amounts owed, and these contracts are expected to be netted/merged, with settlement only for any remainder amount.

OnLedgerAsset

abstract class OnLedgerAsset<T : Any, out C : CommandData, S : FungibleAsset<T>> : Contract

An asset transaction may split and merge assets represented by a set of (issuer, depositRef) pairs, across multiple input and output states. Imagine a Bitcoin transaction but in which all UTXOs had a colour (a blend of issuer+depositRef) and you couldn't merge outputs of two colours together, but you COULD put them in the same transaction.

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. 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.