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.buildPsbt constructs an unsigned PSBT without broadcasting it. Use it when you need to inspect, modify, batch, or co-sign a transaction before sending. See What is a PSBT? in the overview for context.

Example

import 'package:dynamic_sdk/dynamic_sdk.dart';

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

final unsignedPsbt = await sdk.bitcoin.buildPsbt(
  walletId: wallet.id,
  recipientAddress: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
  amount: '10000',         // satoshis
  feePriority: 'medium',
);
print('Unsigned PSBT (base64): $unsignedPsbt');

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'.

Returns

Future<String> — the unsigned PSBT, base64-encoded. Pass it to signPsbt to sign, then to sendRawTransaction to broadcast.

Build → sign → broadcast

final unsignedPsbt = await sdk.bitcoin.buildPsbt(
  walletId: wallet.id,
  recipientAddress: 'bc1q...',
  amount: '5000',
);

final signedPsbt = await sdk.bitcoin.signPsbt(
  walletId: wallet.id,
  request: {'unsignedPsbtBase64': unsignedPsbt},
);

final txId = await sdk.bitcoin.sendRawTransaction(
  walletId: wallet.id,
  rawTransaction: signedPsbt,
);
print('Sent: $txId');