OnLedgerAsset.Companion
Keywords: net.corda.finance.contracts.asset.OnLedgerAsset.Companion class
Date: 2023-09-18

net.corda.finance.contracts.asset

## Class OnLedgerAsset.Companion

- net.corda.finance.contracts.asset.OnLedgerAsset.Companion

- Enclosing class:
    OnLedgerAsset<T,C extends CommandData,S extends FungibleAsset<T>>

      public static class OnLedgerAsset.Companion

- - ### Method Detail

    - #### generateSpend

          @JvmStatic
           @NotNull
          public <S extends FungibleAsset<T>,T> kotlin.Pair<net.corda.core.transactions.TransactionBuilder,java.util.List> generateSpend(@NotNull
                                                                                                                                                              TransactionBuilder tx,
                                                                                                                                                              @NotNull
                                                                                                                                                              Amount<T> amount,
                                                                                                                                                              @NotNull
                                                                                                                                                              AbstractParty to,
                                                                                                                                                              @NotNull
                                                                                                                                                              java.util.List<? extends net.corda.core.contracts.StateAndRef<? extends S>> acceptableStates,
                                                                                                                                                              @NotNull
                                                                                                                                                              AbstractParty payChangeTo,
                                                                                                                                                              @NotNull
                                                                                                                                                              kotlin.jvm.functions.Function3<? super net.corda.core.contracts.TransactionState<? extends S>,? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? super net.corda.core.identity.AbstractParty,? extends net.corda.core.contracts.TransactionState<? extends S>> deriveState,
                                                                                                                                                              @NotNull
                                                                                                                                                              kotlin.jvm.functions.Function0<? extends net.corda.core.contracts.CommandData> generateMoveCommand)

      Generate a transaction that moves an amount of currency to the given pubkey.

      Note: an `class Amount` of Currency is only fungible for a given Issuer Party within a `interface FungibleAsset`

      Parameters:
        `tx` - A builder, which may contain inputs, outputs and commands already. The relevant components needed to move the cash will be added on top.
        `amount` - How much currency to send.
        `to` - a key of the recipient.
        `acceptableStates` - a list of acceptable input states to use.
        `payChangeTo` - party to pay any change to; this is normally a confidential identity of the callingparty.
        `deriveState` - a function to derive an output state based on an input state, amount for the outputand public key to pay to.
      Returns:
        A Pair of the same transaction builder passed in as `tx`, and the list of keys that need to sign the resulting transaction for it to be valid.
      Throws:
        `InsufficientBalanceException` - when a cash spending transaction fails because there is insufficient quantity for a given currency (and optionally set of Issuer Parties).
      See Also:
        `class Amount`, Currency, `interface FungibleAsset`

    - #### generateSpend

          @JvmStatic
           @NotNull
          public <S extends FungibleAsset<T>,T> kotlin.Pair<net.corda.core.transactions.TransactionBuilder,java.util.List> generateSpend(@NotNull
                                                                                                                                                              TransactionBuilder tx,
                                                                                                                                                              @NotNull
                                                                                                                                                              java.util.List<net.corda.finance.contracts.asset.PartyAndAmount> payments,
                                                                                                                                                              @NotNull
                                                                                                                                                              java.util.List<? extends net.corda.core.contracts.StateAndRef<? extends S>> acceptableStates,
                                                                                                                                                              @NotNull
                                                                                                                                                              AbstractParty payChangeTo,
                                                                                                                                                              @NotNull
                                                                                                                                                              kotlin.jvm.functions.Function3<? super net.corda.core.contracts.TransactionState<? extends S>,? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? super net.corda.core.identity.AbstractParty,? extends net.corda.core.contracts.TransactionState<? extends S>> deriveState,
                                                                                                                                                              @NotNull
                                                                                                                                                              kotlin.jvm.functions.Function0<? extends net.corda.core.contracts.CommandData> generateMoveCommand)

      Adds to the given transaction states that move amounts of a fungible asset to the given parties, using only the provided acceptable input states to find a solution (not all of them may be used in the end). A change output will be generated if the state amounts don't exactly fit.

      The fungible assets must all be of the same type and the amounts must be summable i.e. amounts of the same token.

      Type Parameters:
        `S` -

        A fungible asset state type

        `T` -

        A type representing a token

      Parameters:
        `tx` - A builder, which may contain inputs, outputs and commands already. The relevant components needed to move the cash will be added on top.
        `acceptableStates` - a list of acceptable input states to use.
        `payChangeTo` - party to pay any change to; this is normally a confidential identity of the callingparty. We use a new confidential identity here so that the recipient is not identifiable.
        `deriveState` - a function to derive an output state based on an input state, amount for the outputand public key to pay to.
      Returns:
        A Pair of the same transaction builder passed in as `tx`, and the list of keys that need to sign the resulting transaction for it to be valid.
      Throws:
        `InsufficientBalanceException` - when a cash spending transaction fails because there is insufficient quantity for a given currency (and optionally set of Issuer Parties).

    - #### generateExit

          @JvmStatic
           @Deprecated
           @NotNull
          public <S extends FungibleAsset<T>,T> java.util.Set<java.security.PublicKey> generateExit(@NotNull
                                                                                                                                      TransactionBuilder tx,
                                                                                                                                      @NotNull
                                                                                                                                      Amount<net.corda.core.contracts.Issued> amountIssued,
                                                                                                                                      @NotNull
                                                                                                                                      java.util.List<? extends net.corda.core.contracts.StateAndRef<? extends S>> assetStates,
                                                                                                                                      @NotNull
                                                                                                                                      kotlin.jvm.functions.Function3<? super net.corda.core.contracts.TransactionState<? extends S>,? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? super net.corda.core.identity.AbstractParty,? extends net.corda.core.contracts.TransactionState<? extends S>> deriveState,
                                                                                                                                      @NotNull
                                                                                                                                      kotlin.jvm.functions.Function0<? extends net.corda.core.contracts.CommandData> generateMoveCommand,
                                                                                                                                      @NotNull
                                                                                                                                      kotlin.jvm.functions.Function1<? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? extends net.corda.core.contracts.CommandData> generateExitCommand)

      Deprecated.

      Generate an transaction exiting fungible assets from the ledger.

      Parameters:
        `tx` - transaction builder to add states and commands to.
        `amountIssued` - the amount to be exited, represented as a quantity of issued currency.
        `assetStates` - the asset states to take funds from. No checks are done about ownership of these states, it isthe responsibility of the caller to check that they do not attempt to exit funds held by others.
      Returns:
        the public keys which must sign the transaction for it to be valid.

    - #### generateExit

          @JvmStatic
           @NotNull
          public <S extends FungibleAsset<T>,T> java.util.Set<java.security.PublicKey> generateExit(@NotNull
                                                                                                                         TransactionBuilder tx,
                                                                                                                         @NotNull
                                                                                                                         Amount<net.corda.core.contracts.Issued> amountIssued,
                                                                                                                         @NotNull
                                                                                                                         java.util.List<? extends net.corda.core.contracts.StateAndRef<? extends S>> assetStates,
                                                                                                                         @NotNull
                                                                                                                         AbstractParty payChangeTo,
                                                                                                                         @NotNull
                                                                                                                         kotlin.jvm.functions.Function3<? super net.corda.core.contracts.TransactionState<? extends S>,? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? super net.corda.core.identity.AbstractParty,? extends net.corda.core.contracts.TransactionState<? extends S>> deriveState,
                                                                                                                         @NotNull
                                                                                                                         kotlin.jvm.functions.Function0<? extends net.corda.core.contracts.CommandData> generateMoveCommand,
                                                                                                                         @NotNull
                                                                                                                         kotlin.jvm.functions.Function1<? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? extends net.corda.core.contracts.CommandData> generateExitCommand)

      Generate an transaction exiting fungible assets from the ledger.

      Parameters:
        `tx` - transaction builder to add states and commands to.
        `amountIssued` - the amount to be exited, represented as a quantity of issued currency.
        `assetStates` - the asset states to take funds from. No checks are done about ownership of these states, it isthe responsibility of the caller to check that they do not attempt to exit funds held by others.
        `payChangeTo` - party to pay any change to; this is normally a confidential identity of the callingparty.
      Returns:
        the public keys which must sign the transaction for it to be valid.

    - #### generateIssue

          @JvmStatic
           @NotNull
          public <S extends FungibleAsset<T>,T> java.util.Set<java.security.PublicKey> generateIssue(@NotNull
                                                                                                                          TransactionBuilder tx,
                                                                                                                          @NotNull
                                                                                                                          TransactionState<? extends S> transactionState,
                                                                                                                          @NotNull
                                                                                                                          CommandData issueCommand)

      Puts together an issuance transaction for the specified state. Normally contracts will provide convenient wrappers around this function, which build the state for you, and those should be used in preference.