core / Contract

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.



Properties

legalContractReference abstract val legalContractReference: SecureHash

Unparsed reference to the natural language contract that this code is supposed to express (usually a hash of the contracts contents).

Functions

verify abstract fun verify(tx: TransactionForVerification): Unit

Takes an object that represents a state transition, and ensures the inputs/outputs/commands make sense. Must throw an exception if theres 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.

Inheritors

Cash class Cash : Contract

A cash transaction may split and merge money 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 couldnt merge outputs of two colours together, but you COULD put them in the same transaction.

CommercialPaper class CommercialPaper : Contract
CrowdFund class CrowdFund : Contract

This is a basic crowd funding contract. It allows a party to create a funding opportunity, then for others to pledge during the funding period , and then for the party to either accept the funding (if the target has been reached) return the funds to the pledge-makers (if the target has not been reached).

DummyContract class DummyContract : Contract