spark_transfer

This method is coming πŸ”œ

You can use the spark_transfer method to send Spark BTC from the user’s wallet to any valid Spark address.

Parameters

Request parameters
Description

reciverSparkAddress

a string representing the destination Spark address Example: "sprt1pgssyuuuhnrrdjswal5c3s3rafw9w3y5dd4cjy3duxlf7hjzkp0rqx6dj6mrhu"

amountSats

a string representing the amount of BTC to transfer, in satoshis.

Example

import { request } from "sats-connect";

try {
  const response = await request("spark_transfer", {
    receiverSparkAddress: "sprt1pgssyuuuhnrrdjswal5c3s3rafw9w3y5dd4cjy3duxlf7hjzkp0rqx6dj6mrhu",
    amountSats: 100, // Amount to send, in satoshis
  });

  if ("result" in response) {
    console.log("Spark transfer successful:", response.result.txid);
  } else {
    console.error("Spark transfer failed:", response.error.message);
  }
} catch (error) {
  console.error("Unexpected error:", error);
}

What spark_transfer does

Calling this method prompts the user to:

  1. Review the recipient address and amount of Spark BTC to send.

  2. Approve the transaction in their Xverse wallet.

  3. Upon approval, the transaction is signed and broadcasted to the Spark network.

The spark_transfer method returns a Promise that resolves to a SparkTransferResult :

Property
Description

txid

a hex-encoded string representing the ID of the broadcasted BTC transfer transaction on Spark

Last updated