TxBalancingError

scalus.cardano.txbuilder.TxBalancingError

Transaction balancing error types.

These errors can occur during the transaction balancing process, which iteratively adjusts fees and change outputs until the transaction is balanced (consumed == produced).

Attributes

Graph
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Type members

Enum entries

final case class BalanceDidNotConverge(iterations: Int)

Balancing loop exceeded maximum iterations without converging.

Balancing loop exceeded maximum iterations without converging.

This typically indicates a pathological case where fee adjustments and change calculations keep oscillating. The transaction structure may need to be simplified.

Value parameters

iterations

the number of iterations attempted before giving up

Attributes

Plutus script evaluation failed during balancing.

Plutus script evaluation failed during balancing.

This occurs when a Plutus validator or minting policy fails execution. The cause contains detailed error information including execution logs.

Value parameters

cause

the Plutus script evaluation exception with logs and error details

Attributes

final case class Failed(cause: Throwable)

Generic failure during balancing.

Generic failure during balancing.

Catches unexpected errors that don't fit other categories, such as CBOR encoding issues or internal errors.

Value parameters

cause

the underlying exception

Attributes

final case class InsufficientCollateralForReturn(totalCollateralAda: Coin, requiredCollateral: Coin, minAdaForReturn: Coin)

Error when collateral contains tokens but there's insufficient ADA to create a valid collateral return output.

Error when collateral contains tokens but there's insufficient ADA to create a valid collateral return output.

Per Babbage spec, tokens in collateral MUST be returned via collateralReturnOutput, which requires meeting the minAda requirement. This error occurs when: totalCollateralAda < requiredCollateral + minAdaForReturn

Value parameters

minAdaForReturn

minimum ADA needed for the collateral return output

requiredCollateral

ADA needed for collateral (percentage of fee)

totalCollateralAda

total ADA in all collateral inputs

Attributes

final case class InsufficientFunds(valueDiff: Value, minRequired: Long)

Insufficient funds to balance the transaction.

Insufficient funds to balance the transaction.

This error indicates that the transaction outputs (including fees) exceed what the inputs can provide. The valueDiff contains the full deficit including both ADA and native tokens.

When valueDiff has negative values, those represent the amounts needed:

  • Negative ADA means more lovelace is needed
  • Negative token amounts mean more of those tokens are needed

Value parameters

minRequired

minimum additional lovelace needed, accounting for minAda requirements on change outputs

valueDiff

the value difference (consumed - produced). Negative values indicate deficit.

Attributes