Input selector that implements a "large-first" strategy.

This strategy selects the largest UTxOs per asset, one asset at a time, until the requirements of all assets in the outputs + fees and implicit values are satisfied.

Hierarchy

  • LargeFirstSelector

Implements

Constructors

Properties

Methods

  • Aggregate Lovelace that enters and leaves the transaction, taking implicit withdrawals / deposits into account.

    Returns

    An object with totalIn — Lovelace provided by UTxOs + withdrawals totalOut — Lovelace required for explicit outputs + deposits

    Parameters

    • inputs: Value[]

      Array of Values held by the selected UTxOs.

    • outputs: Value[]

      Array of explicit transaction outputs.

    • Optional implicit: ImplicitValue

      Optional implicit values.

    Returns {
        totalIn: bigint;
        totalOut: bigint;
    }

    • totalIn: bigint
    • totalOut: bigint
  • Computes the total Lovelace and asset output requirements, including the effects of implicit values such as key deposits, withdrawals, and minting/burning.

    Minting and burning are treated as negative or positive contributions to input balance, and are subtracted from the output requirements.

    Returns

    An object with: totalLovelaceInput: Sum of all input Lovelace, including withdrawals. totalLovelaceOutput: Sum of all output Lovelace, including deposits. outputAssets: Asset requirements after accounting for minting/burning.

    Throws

    If balance is insufficient to satisfy the target.

    Parameters

    • inputs: Set<Utxo>

      The full set of selected UTxOs (including pre-selected).

    • outputs: Set<TxOut>

      The transaction outputs.

    • Optional implicitValue: ImplicitValue

      Optional implicit values including deposits, withdrawals, and minting.

    Returns {
        outputAssets: TokenMap;
        totalLovelaceInput: bigint;
        totalLovelaceOutput: bigint;
    }

    • outputAssets: TokenMap
    • totalLovelaceInput: bigint
    • totalLovelaceOutput: bigint
  • Select additional UTxOs until the fee and min-Ada requirements are satisfied, then build the final change outputs.

    Returns

    An object containing Set of all inputs that will appear in the tx body, minimum fee returned by the cost model and an Array of change outputs.

    Parameters

    • initialInputs: Set<Utxo>

      The UTxOs already chosen for assets and/or pre-selected by the wallet.

    • outputs: Set<TxOut>

      The explicit transaction outputs.

    • allAvailable: Utxo[]

      Every UTxO the wallet can spend (pre-selected ∪ utxo).

    • requiredAssets: TokenMap

      Aggregate asset requirements computed from outputs + burn. Used for fee/Ada expansion.

    • constraints: SelectionConstraints

      Network / wallet selection constraints (min-Ada, fee estimator, bundle size, limit…).

    • changeAddressResolver: ChangeAddressResolver

      Callback that assigns addresses (or further splits) for the provisional change bundles returned by the fee engine.

    • Optional implicitValue: ImplicitValue

      Optional implicit components (deposits, withdrawals, mint or burn)

    Returns Promise<{
        change: TxOut[];
        fee: bigint;
        finalSelection: Set<Utxo>;
    }>

  • Selects the largest UTxOs per required asset until each target amount is fulfilled.

    Returns

    A set of selected UTxOs covering the asset requirements.

    Throws

    If any asset cannot be sufficiently fulfilled.

    Parameters

    • requiredAssets: Map<AssetId, bigint>

      The asset quantities required by the transaction outputs.

    • allAvailable: Utxo[]

      All available UTxOs (including preselected ones).

    • preSelected: Utxo[]

      The UTxOs already selected for the transaction.

    Returns Set<Utxo>

  • Selects UTxOs (largest Ada first) until the total Lovelace covers the target amount.

    Returns

    A new set including the original selected UTxOs plus any added for Ada coverage.

    Throws

    If the Lovelace requirement cannot be fulfilled.

    Parameters

    • target: bigint

      The required amount of Lovelace.

    • allAvailable: Utxo[]

      All available UTxOs.

    • selected: Set<Utxo>

      The current set of already selected UTxOs.

    • implicitCoinInput: bigint

      The implicit coin input amount.

    Returns Set<Utxo>

Generated using TypeDoc