Skip to main content

Documentation Index

Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt

Use this file to discover all available pages before exploring further.

DynamicSDK.instance.bitcoin.sendBitcoin builds, signs, and broadcasts a Bitcoin transfer in a single call. Use it when you don’t need to inspect or modify the PSBT before broadcast — see Build a PSBT and Sign a PSBT for the manual flow.

Example

import 'package:dynamic_sdk/dynamic_sdk.dart';

final sdk = DynamicSDK.instance;
final wallet = sdk.wallets.userWallets.firstWhere(
  (w) => w.chain == 'BTC',
);

final txId = await sdk.bitcoin.sendBitcoin(
  walletId: wallet.id,
  recipientAddress: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
  amount: '50000',          // 50_000 sats = 0.0005 BTC
  feePriority: 'medium',    // optional: 'high', 'medium', or 'low'
);
print('Broadcasted: $txId');

Parameters

ParameterTypeDescription
walletIdStringThe id of a wallet whose chain == 'BTC'.
recipientAddressStringDestination address.
amountStringAmount in satoshis, encoded as a string to preserve precision.
feePriorityString?Fee tier: 'high', 'medium', or 'low'. Defaults are connector-specific.

Returns

Future<String> — the broadcasted transaction id (txid).

Converting BTC to satoshis

amount is always a satoshi string. 1 BTC = 100,000,000 satoshis. Convert from a user-supplied BTC value before calling:
String btcToSats(double btc) =>
    BigInt.from((btc * 100000000).round()).toString();

final txId = await sdk.bitcoin.sendBitcoin(
  walletId: wallet.id,
  recipientAddress: 'bc1q...',
  amount: btcToSats(0.001), // '100000'
);