sdk/builders/CoinSelection.ts
CoinSelection overview
Table of contents
coin-selection
largestFirstSelection
Largest-first coin selection algorithm.
Strategy:
- Sort UTxOs by total lovelace value (descending)
- Select UTxOs one by one until all required assets are covered
- Return selected UTxOs
Advantages:
- Simple and predictable
- Minimizes number of inputs (uses largest UTxOs first)
- Fast execution
Disadvantages:
- May select more value than needed (more change)
- Doesn't optimize for minimum fee
- Doesn't consider UTxO fragmentation
Use cases:
- Default algorithm for simple transactions
- When minimizing input count is priority
- When speed is more important than optimization
Signature
export declare const largestFirstSelection: CoinSelectionFunctionAdded in v2.0.0
utils
CoinSelectionAlgorithm (type alias)
Signature
export type CoinSelectionAlgorithm = "largest-first" | "random-improve" | "optimal"CoinSelectionError (class)
Signature
export declare class CoinSelectionErrorCoinSelectionFunction (type alias)
Signature
export type CoinSelectionFunction = (
availableUtxos: ReadonlyArray<UTxO.UTxO>,
requiredAssets: CoreAssets.Assets
) => CoinSelectionResultCoinSelectionResult (interface)
Signature
export interface CoinSelectionResult {
readonly selectedUtxos: ReadonlyArray<UTxO.UTxO>
}