Sats Connect - Wallet API for Bitcoin & Stacks
  • Introduction
  • Wallet Providers
    • getInfo
    • getProviders & getProviderById
  • Connecting to the wallet
    • Connect to Xverse Wallet
    • Disconnect from Xverse Wallet
    • Connect to other wallets
      • Manage a user's default wallet
    • [Legacy ⚠️] getAccounts
  • Wallet Methods
    • request methods
    • wallet_getAccount
    • wallet_getNetwork
    • wallet_changeNetwork
    • Xverse Custom Methods
  • Xverse Wallet Permissions
  • Xverse Wallet events
  • BITCOIN METHODS
    • 🟠getAddresses
    • 🟠signMessage
    • 🟠signPsbt
    • 🟠sendTransfer
    • 🟠signMultipleTransactions
    • 🟠getBalance
    • 🎨createInscription
    • 🎨createRepeatInscriptions
    • 🎨ord_getInscriptions
    • 🎨ord_sendInscriptions
    • 🔲runes_getBalance
    • 🔲runes_transfer
    • 🔲Mint Runes
      • runes_estimateMint
      • runes_mint
    • 🔲Etch Runes
      • runes_estimateEtch
      • runes_etch
    • 🔲runes_getOrder
    • 🔲Speed up a Rune Mint or Etch order
      • 🔲runes_estimateRbfOrder
      • 🔲runes_rbfOrder
  • STACKS METHODS
    • 🔴stx_getAccounts
    • 🔴stx_signMessage
    • 🔴stx_signStructuredMessage
    • 🔴stx_transferStx
    • 🔴stx_signTransaction
    • 🔴stx_callContract
    • 🔴stx_deployContract
  • GUIDES
    • Verify Bitcoin message signatures
    • Creating Bitcoin PSBTs
    • 📱Mobile Integration
    • Next.js support
  • RESOURCES
    • App Template
    • Demo App
    • Changelog
    • Github Issues
    • Developer forum
    • BIP322
Powered by GitBook
On this page
  1. BITCOIN METHODS

sendTransfer

You can use the sendTransfer method to request a transfer of any amount of Bitcoin to one or more recipients from the user's wallet.

Request parameters
Description

recipients

an array of objects with <address, amount> properties:

  • address a string representing the recipient's address

  • amount a number representing the amount of Bitcoin to send, denominated in satoshis (Bitcoin base unit)

import {
  request,
  BitcoinNetworkType,
  RpcErrorCode,
} from "sats-connect";

try {
  const response = await request("sendTransfer", {
    recipients: [
      {
        address: recipient,
        amount: Number(amount),
      },
    ],
  });
  if (response.status === "success") {
    // handle success
  } else {
    if (response.error.code === RpcErrorCode.USER_REJECTION) {
      // handle user cancellation error
    } else {
      // handle error
    }
  }
} catch (err) {
    alert(err.error.message);
}

The user will be prompted to review the Bitcoin transfer transaction in the wallet, and to confirm:

  • the recipients and amounts to send

  • their desired transaction fee

The transaction will be signed and broadcasted upon user approval.

The sendTransfer method returns a Promise that resolves to the sendTransferResult object:

Property
Description

txid

The transaction id as a hex-encoded string.

PrevioussignPsbtNextsignMultipleTransactions

Last updated 5 months ago

🟠