Send Transactions
Send BTC and estimate transaction fees.
This guide explains how to send BTC, extend post-broadcast polling, sign without broadcasting, quote and broadcast signed hex, estimate fees before sending, cap transaction fees, use a custom fee rate, and target a specific confirmation time.
Send BTC
You can send Bitcoin to a recipient using account.sendTransaction():
const result = await account.sendTransaction({
to: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
value: 100000n // 0.001 BTC in satoshis
})
console.log('Transaction hash:', result.hash)
console.log('Transaction fee:', result.fee, 'satoshis')Bitcoin transactions support a single recipient only. Amounts and fees are always in satoshis (1 BTC = 100,000,000 satoshis). The minimum amount must be above the dust limit (294 satoshis for SegWit, 546 for legacy).
Extend Post-Broadcast Polling
If you want account.sendTransaction() to keep polling after broadcast until spent inputs disappear from the unspent-output set, pass the optional timeoutMs argument:
const result = await account.sendTransaction(
{
to: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
value: 100000n,
},
30000
)
console.log('Transaction hash:', result.hash)If you omit timeoutMs, the wallet uses the default post-broadcast polling window before returning.
Sign Without Broadcasting
Use account.signTransaction() when your app needs a signed raw Bitcoin transaction but does not want WDK to broadcast it immediately.
const signedTransaction = await account.signTransaction({
to: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
value: 100000n,
feeRate: 10n
})
console.log('Signed transaction:', signedTransaction)signTransaction() returns the signed transaction hex. Use sendTransaction() when WDK should sign, broadcast, and return the transaction hash.
Quote and Broadcast Signed Hex
A writable Bitcoin account can quote and broadcast a previously signed raw transaction. The wallet broadcasts the supplied hex without rebuilding or signing it again.
const signedTransaction = await account.signTransaction({
to: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
value: 100000n,
feeRate: 10n
})
const quote = await account.quoteSendTransaction(signedTransaction)
console.log('Signed transaction fee:', quote.fee, 'satoshis')
const result = await account.sendTransaction(signedTransaction)
console.log('Transaction hash:', result.hash)Signed-hex quoting parses the transaction and fetches its referenced previous transactions through the configured client. It requires network access and does not broadcast. Broadcasting applies transactionMaxFee when configured, but signature validity is ultimately checked by the Bitcoin network rather than pre-validated by this method.
Estimate Fees
You can estimate the fee for a transaction without broadcasting it using account.quoteSendTransaction():
const quote = await account.quoteSendTransaction({
to: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
value: 100000n
})
console.log('Estimated fee:', quote.fee, 'satoshis')Cap Transaction Fees
Set transactionMaxFee when you create the wallet to stop sendTransaction() or signTransaction() if the estimated native BTC fee is too high.
const wallet = new WalletManagerBtc(seedPhrase, {
network: 'bitcoin',
transactionMaxFee: 10000n // satoshis
})Send with Custom Fee Rate
You can override automatic fee estimation by providing a feeRate in sat/vB to account.sendTransaction():
const result = await account.sendTransaction({
to: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
value: 100000n,
feeRate: 10n // sat/vB
})When feeRate is provided, the confirmationTarget parameter is ignored.
Send with Confirmation Target
You can target a specific number of blocks for confirmation using the confirmationTarget parameter in account.sendTransaction():
const result = await account.sendTransaction({
to: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
value: 100000n,
confirmationTarget: 6 // target 6 blocks (~1 hour)
})Next Steps
Learn how to view transaction history.