sdk.txbuilder.estimatesubtransaction
Home > @blaze-cardano/sdk > TxBuilder > estimateSubTransaction
TxBuilder.estimateSubTransaction() method
Estimates a sub-transaction without completing it. Runs the pre-complete hooks but otherwise leaves the builder unchanged.
Signature:
estimateSubTransaction(surplus?: Value): Promise<{
deficit: Value;
fee: bigint;
signedSize: number;
}>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
surplus |
Value |
(Optional) What the sub-transaction will leave for the batch to collect (for example a payment), as it will be passed to . Defaults to none. |
Returns:
Promise<{ deficit: Value; fee: bigint; signedSize: number; }>
The deficit the wallet can't cover (non-positive entries; pass value.merge(deficit, surplus) to ), the fee this sub-transaction adds to the top-level transaction's minimum fee at the builder's protocol parameters, and its signedSize in bytes once its vkey witnesses are added.
fee counts this sub-transaction's reference scripts at the first price tier; reference scripts elsewhere in the batch can raise it. It leaves out costs that fall on the top-level transaction itself: its sub-transaction list framing, vkey witnesses for key guards it is required to carry, and guard script execution.
When the wallet can't cover the sub-transaction (or lacks an asset in surplus), the estimate spends every spare UTxO, so fee and signedSize can exceed what then builds. CIP-0118 is not live on mainnet; this API may change.