corda / net.corda.finance.contracts.asset

Package net.corda.finance.contracts.asset

Cash states, obligations and commodities.

WARNING: NOT API STABLE.

Types

BilateralNetState

data class BilateralNetState<P : Any> : NetState<P>

Subset of state, containing the elements which must match for two obligation transactions to be nettable. If two obligation state objects produce equal bilateral net states, they are considered safe to net directly. Bilateral states are used in close-out netting.

Cash

class Cash : OnLedgerAsset<Currency, Commands, State>

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 couldn't merge outputs of two colours together, but you COULD put them in the same transaction.

CashSelection

interface CashSelection

Pluggable interface to allow for different cash selection provider implementations Default implementation CashSelectionH2Impl uses H2 database and a custom function within H2 to perform aggregation. Custom implementations must implement this interface and declare their implementation in META-INF/services/net.corda.contracts.asset.CashSelection

CommodityContract

class CommodityContract : OnLedgerAsset<Commodity, Commands, State>

A commodity contract represents an amount of some commodity, tracked on a distributed ledger. The design of this contract is intentionally similar to the Cash contract, and the same commands (issue, move, exit) apply, the differences are in representation of the underlying commodity. Issuer in this context means the party who has the commodity, or is otherwise responsible for delivering the commodity on demand, and the deposit reference is use for internal accounting by the issuer (it might be, for example, a warehouse and/or location within a warehouse).

MultilateralNetState

data class MultilateralNetState<P : Any> : NetState<P>

Subset of state, containing the elements which must match for two or more obligation transactions to be candidates for netting (this does not include the checks to enforce that everyone's amounts received are the same at the end, which is handled under the verify() function). In comparison to BilateralNetState, this doesn't include the parties' keys, as ensuring balances match on input and output is handled elsewhere. Used in cases where all parties (or their proxies) are signing, such as central clearing.

NetState

interface NetState<P : Any>

Common interface for the state subsets used when determining nettability of two or more states. Exposes the underlying issued thing.

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

PartyAndAmount

data class PartyAndAmount<T : Any>

A simple holder for a (possibly anonymous) AbstractParty and a quantity of tokens

Properties

CASH

val Amount<Currency>.CASH: State

An extension property that lets you write 100.DOLLARS.CASH

CASH_PROGRAM_ID

const val CASH_PROGRAM_ID: ContractClassName

DUMMY_CASH_ISSUER

val DUMMY_CASH_ISSUER: PartyAndReference

A dummy, randomly generated issuer party by the name of "Snake Oil Issuer"

DUMMY_CASH_ISSUER_KEY

val DUMMY_CASH_ISSUER_KEY: KeyPair

A randomly generated key.

DUMMY_OBLIGATION_ISSUER

val DUMMY_OBLIGATION_ISSUER: Party

A dummy, randomly generated issuer party by the name of "Snake Oil Issuer"

DUMMY_OBLIGATION_ISSUER_KEY

val DUMMY_OBLIGATION_ISSUER_KEY: KeyPair

A randomly generated key.

OBLIGATION_PROGRAM_ID

const val OBLIGATION_PROGRAM_ID: ContractClassName

STATE

val Amount<Issued<Currency>>.STATE: State

An extension property that lets you get a cash state from an issued token, under the NULL_PARTY

Functions

at

infix fun <T : Any> State<T>.at(dueBefore: Instant): State<T>

between

infix fun <T : Any> State<T>.between(parties: Pair<AbstractParty, AbstractParty>): State<T>

extractAmountsDue

fun <P : Any> extractAmountsDue(product: Terms<P>, states: Iterable<State<P>>): Map<Pair<AbstractParty, AbstractParty>, Amount<Terms<P>>>

Convert a list of settlement states into total from each obligor to a beneficiary.

issued by

infix fun <T : Any> State<T>.issued by(party: AbstractParty): State<T>

issuedBy

fun <T : Any> State<T>.issuedBy(party: AnonymousParty): State<T>

netAmountsDue

fun <P : AbstractParty, T : Any> netAmountsDue(balances: Map<Pair<P, P>, Amount<T>>): Map<Pair<P, P>, Amount<T>>

Net off the amounts due between parties.

owned by

infix fun <T : Any> State<T>.owned by(owner: AbstractParty): State<T>

ownedBy

fun <T : Any> State<T>.ownedBy(owner: AbstractParty): State<T>

sumAmountsDue

fun <P : AbstractParty, T : Any> sumAmountsDue(balances: Map<Pair<P, P>, Amount<T>>): Map<P, Long>

Calculate the total balance movement for each party in the transaction, based off a summary of balances between each obligor and beneficiary.