com.r3corda.contracts.asset / Cash

# Cash

`class Cash : ClauseVerifier`

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.

The goal of this design is to ensure that money can be withdrawn from the ledger easily: if you receive some money via this contract, you always know where to go in order to extract it from the R3 ledger, no matter how many hands it has passed through in the intervening time.

At the same time, other contracts that just want money and dont care much who is currently holding it in their vaults can ignore the issuer/depositRefs and just examine the amount fields.

### Types

Clauses | `interface Clauses`
Commands | `interface Commands : Commands`
State | `data class State : FungibleAsset<Currency>` A state representing a cash claim against some party

### Constructors

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

### Properties

clauses | `val clauses: List<SingleClause>`
legalContractReference | `val legalContractReference: SecureHash` TODO:

### Functions

extractCommands | `fun extractCommands(tx: TransactionForContract): List<AuthenticatedObject<Commands>>`
generateExit | `fun generateExit(tx: TransactionBuilder, amountIssued: Amount<Issued<Currency>>, changeKey: PublicKey, cashStates: List<StateAndRef<State>>): PublicKey` Generate an transaction exiting cash from the ledger.
generateIssue | `fun generateIssue(tx: TransactionBuilder, tokenDef: Issued<Currency>, pennies: Long, owner: PublicKey, notary: Party): Unit` Puts together an issuance transaction from the given template, that starts out being owned by the given pubkey. `fun generateIssue(tx: TransactionBuilder, amount: Amount<Issued<Currency>>, owner: PublicKey, notary: Party): Unit` Puts together an issuance transaction for the specified amount that starts out being owned by the given pubkey.
generateSpend | `fun generateSpend(tx: TransactionBuilder, amount: Amount<Issued<Currency>>, to: PublicKey, cashStates: List<StateAndRef<State>>): List<PublicKey>` `fun generateSpend(tx: TransactionBuilder, amount: Amount<Currency>, to: PublicKey, cashStates: List<StateAndRef<State>>, onlyFromParties: Set<Party>? = null): List<PublicKey>` Generate a transaction that consumes one or more of the given input states to move money to the given pubkey. Note that the wallet list is not updated: its up to you to do that.

### Inherited Functions

verify | `open fun verify(tx: TransactionForContract): 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.