stx_transferStx

A helper method to transfer STX.

Method name

stx_transferStx

Request a transfer of STX tokens to a specified recipient.

Parameters

Parameter
Description
Required
Type

recipient

Stacks c32-encoded address of the recipient

string

amount

Amount of STX to transfer (BigInt constructor compatible)

number | string

memo

Optional memo for the transaction (defaults to an empty string)

string

Example request

try {
  // Request STX transfer
  const response = await window.LeatherProvider.request("stx_transferStx", {
    recipient: "SP2J4V1A3Q0GJ6ZQ0H9D6X90XZJQ2A0WQ5P0K2RDS",
    amount: "1000000", // 1 STX (in microSTX)
    memo: "Payment for services",
  });

  console.log("Response:", response);
} catch (error) {
  console.log("Request error:", error);
}

Example response

{
    "jsonrpc": "2.0",
    "id": "d3f1a7b0-5e6c-4f18-92a4-8e3b9f7c5c71",
    "result": {
        "txid": "f9c2a8f1e3b1d5a7c8e2f6a9d4b3e1c7f2a5d9b8c6e4f1a3b7d2e9c5f8a1b6c3",
        "transaction": "dead...beef"
    }
}

Last updated