spark_transfer
You can use the spark_transfer
method to send Spark BTC from the userβs wallet to any valid Spark address.
Parameters
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:
Review the recipient address and amount of Spark BTC to send.
Approve the transaction in their Xverse wallet.
Upon approval, the transaction is signed and broadcasted to the Spark network.
The spark_transfer
method returns a Promise that resolves to a SparkTransferResult
:
txid
a hex-encoded string representing the ID of the broadcasted BTC transfer transaction on Spark
Last updated