Skip to main content
Sends a Bitcoin transaction to a recipient address.

Usage

import { sendBitcoin, isBitcoinWalletAccount } from '@dynamic-labs-sdk/bitcoin';
import { getPrimaryWalletAccount } from '@dynamic-labs-sdk/client';

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isBitcoinWalletAccount(walletAccount)) {
  const { transactionId } = await sendBitcoin({
    walletAccount,
    transaction: {
      recipientAddress: 'RECIPIENT_BTC_ADDRESS',
      amount: 10000n, // Amount in satoshis
    },
  });

  console.log('Transaction sent:', transactionId);
}

Parameters

ParameterTypeDescription
transaction.recipientAddressstringThe recipient’s Bitcoin address
transaction.amountbigintThe amount to send in satoshis
walletAccountBitcoinWalletAccountThe wallet account to send from
clientDynamicClient (optional)The Dynamic client instance. Only required when using multiple clients.

Returns

Promise<{ transactionId: string }> - A promise that resolves to an object containing the transaction ID.

Errors

ErrorDescription
NotBitcoinProviderErrorThrown if the wallet account’s provider is not a Bitcoin provider
MethodNotImplementedErrorThrown if the wallet provider does not implement the sendBitcoin method