Skip to content

estimateBTCTransaction ​

estimateBTCTransaction(config, intentions, client, options?): Promise<EstimateBTCTransactionResponse>

Estimates the cost and gas requirements for a Bitcoin transaction with the provided intentions. Calculates gas limits for EVM transactions and total fees without executing the transaction.

Import ​

ts
import { estimateBTCTransaction } from "@midl/executor";

Example ​

ts
import { estimateBTCTransaction } from "@midl/executor";

const {fee, intentions} = await estimateBTCTransaction(config, intentions, client, { feeRate: 10 });
console.log(`Estimated fee: ${fee} satoshis`);
console.log(`Updated intentions:`, intentions);

Parameters ​

NameTypeDescription
configConfigThe configuration object.
intentionsTransactionIntention[]Array of transaction intentions to estimate.
clientClientViem's client instance.
optionsEstimateBTCTransactionOptions (optional)Optional configuration options.

EstimateBTCTransactionOptions ​

NameTypeDescription
stateOverrideStateOverride (optional)State override for EVM transactions.
fromstring (optional)BTC address of the account to use for signing.
feeRatenumber (optional)Custom fee rate (sats/vB).
multisigAddressstring (optional)Multisig address to use for the transaction.
gasMultipliernumber (optional)Multiplier to apply to estimated gas (default: 1.2). Used to avoid gas fluctuations.

Returns ​

Promise<EstimateBTCTransactionResponse> — The estimation response containing fee and updated intentions.

EstimateBTCTransactionResponse ​

NameTypeDescription
feebigintThe estimated total cost in satoshis.
intentionsTransactionIntention[]The cloned intentions with updated gas limits for EVM transactions.

Released under the MIT License