com.r3corda.contracts.asset / Obligation

# Obligation

`class Obligation<P> : 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.

### Parameters

`P` - the product the obligation is for payment of.

### Types

BilateralNetState | `data class BilateralNetState<P> : 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.
Commands | `interface Commands : CommandData`
IssuanceCommands | `interface IssuanceCommands<P> : CommandData` Interface for commands that apply to states grouped by issuance definition
IssuanceDefinition | `data class IssuanceDefinition<P>` Subset of state, containing the elements specified when issuing a new settlement contract. TODO: This needs to be something common to contracts that we can be obliged to pay, and moved out into core accordingly.
Lifecycle | `enum class Lifecycle` Represents where in its lifecycle a contract state is, which in turn controls the commands that can be applied to the state. Most states will not leave the NORMAL lifecycle. Note that settled (as an end lifecycle) is represented by absence of the state on transaction output.
MultilateralNetState | `data class MultilateralNetState<P> : 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 everyones amounts received are the same at the end, which is handled under the verify() function). In comparison to BilateralNetState, this doesnt 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>` Common interface for the state subsets used when determining nettability of two or more states. Exposes the underlying issued thing.
State | `data class State<P> : FungibleAssetState<P, IssuanceDefinition<P>>, BilateralNettableState<State<P>>` A state representing the obligation of one party (obligor) to deliver a specified number of units of an underlying asset (described as issuanceDef.acceptableIssuedProducts) to the beneficiary no later than the specified time.
StateTemplate | `data class StateTemplate<P>` Subset of state, containing the elements specified when issuing a new settlement contract.

### Constructors

<init> | `Obligation()` 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.

### Properties

legalContractReference | `val legalContractReference: SecureHash` TODO:

### Functions

generateCloseOutNetting | `fun generateCloseOutNetting(tx: TransactionBuilder, signer: PublicKey, vararg states: State<P>): Unit` Generate a transaction performing close-out netting of two or more states.
generateIssue | `fun generateIssue(tx: TransactionBuilder, obligor: Party, issuanceDef: StateTemplate<P>, pennies: Long, beneficiary: PublicKey, notary: Party): Unit` Puts together an issuance transaction for the specified amount that starts out being owned by the given pubkey.
generatePaymentNetting | `fun generatePaymentNetting(tx: TransactionBuilder, issued: Issued<P>, notary: Party, vararg states: State<P>): Unit`
generateSetLifecycle | `fun generateSetLifecycle(tx: TransactionBuilder, statesAndRefs: List<StateAndRef<State<P>>>, lifecycle: Lifecycle, notary: Party): Unit` Generate a transaction changing the lifecycle of one or more state objects.
generateSettle | `fun generateSettle(tx: TransactionBuilder, statesAndRefs: Iterable<StateAndRef<State<P>>>, assetStatesAndRefs: Iterable<StateAndRef<FungibleAssetState<P, *>>>, moveCommand: MoveCommand, notary: Party): Unit`
verify | `fun verify(tx: TransactionForContract): Unit` This is the function EVERYONE runs
verifyIssueCommand | `fun verifyIssueCommand(inputs: List<State<P>>, outputs: List<State<P>>, issueCommand: AuthenticatedObject<Issue<P>>, issued: Issued<P>, obligor: Party): Unit`
verifyNetCommand | `fun verifyNetCommand(inputs: Iterable<State<P>>, outputs: Iterable<State<P>>, command: AuthenticatedObject<Net>, netState: NetState<P>): Unit` Verify a netting command. This handles both close-out and payment netting.
verifySetLifecycleCommand | `fun verifySetLifecycleCommand(inputs: List<State<P>>, outputs: List<State<P>>, tx: TransactionForContract, setLifecycleCommand: AuthenticatedObject<SetLifecycle<P>>): Unit` A default command mutates inputs and produces identical outputs, except that the lifecycle changes.