Magic Eden Wallet Developer Docs
  • 👋Welcome
    • Wallet Introduction
  • 📙Bitcoin
    • Diving into Bitcoin
    • Detecting the Provider
    • Connecting to the Wallet
    • Signing a Message
    • Signing a Transaction
    • Sending BTC
    • Provider API Methods
    • Provider Events
    • FAQs
  • 📗Solana
    • Diving Into Solana
    • Solana Wallet Adapter
    • Connect Directly to the ME Solana Provider
    • Signing a Message
    • Sending a Transaction
    • Provider API Methods
    • Provider Events
    • FAQs
  • 📘EVM
    • Diving into the EVM
    • Connect Directly to the ME EVM Provider
    • Signing a Message
    • Sending a Transaction
    • Library Integrations
      • Wallet Connect
      • Rainbow Kit
      • Wagmi
    • Provider API Methods
    • Provider Events
    • FAQs
  • ❓Resources
    • Demo Apps
    • Logos and Brand Assets
Powered by GitBook
On this page
  1. Bitcoin

Sending BTC

PreviousSigning a TransactionNextProvider API Methods

Last updated 11 months ago

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

📙
Sats Connect