Sending BTC

Since creating PSBTs from scratch can be rather intensive, the ME wallet exposes a simple method on the provider called sendBtcTransaction to facilitate the basic request of sending bitcoin to another address.

In pattern with the previous methods, the ME provider extends Sats Connect to ensure a clear format to send BTC.

import { sendBtcTransaction, BitcoinNetworkType } from "sats-connect";

// in a real app, you'll use the ME 'payment' address returned after a connection
const nativeSegwitAddress = 'bc1qcdmvsc8qqk8sr2st3mttu6fsmfrjzh5xrf4dch'
const recipientAddress = 'dummyAddress'

await sendBtcTransaction({
  payload: {
    network: {
      type: BitcoinNetworkType.Mainnet,
    },
    recipients: [
      {
        address: recipientAddress!,
        amountSats: BigInt(1500),
      },
    ],
    senderAddress: nativeSegwitAddress!,
  },
  onFinish: (response) => {
    alert(response);
  },
  onCancel: () => alert("Canceled"),
});

This will prompt the user to send the specified amount of sats to the recipientAddress

Last updated