> For the complete documentation index, see [llms.txt](https://docs.leather.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.leather.io/developers/stacks-methods/stx_signtransaction.md).

# stx\_signTransaction

Request the signature of a Stacks transaction

## Method name

`stx_signTransaction`

Leather signs a transaction your app built and returns it. It does not broadcast. The app must be connected first, through [`getAddresses`](/developers/methods/getaddresses.md). Leather signs with the account the app connected with.

## Parameters

Pass one of two forms.

The SIP-030 form:

| Parameter     | Description                                 | Required | Type     |
| ------------- | ------------------------------------------- | -------- | -------- |
| `transaction` | Hex-encoded serialized unsigned transaction | ✅        | `string` |
| `network`     | Network identifier                          | ❌        | `string` |

The Leather form:

| Parameter      | Description                                         | Required | Type     |
| -------------- | --------------------------------------------------- | -------- | -------- |
| `txHex`        | Hex-encoded serialized unsigned transaction         | ✅        | `string` |
| `network`      | Network identifier                                  | ❌        | `string` |
| `stxAddress`   | Accepted for compatibility. Leather does not use it | ❌        | `string` |
| `attachment`   | Accepted for compatibility. Leather does not use it | ❌        | `string` |
| `accountIndex` | Accepted for compatibility. Leather does not use it | ❌        | `string` |

For a single-signature transaction, Leather replaces the fee and nonce with the values on the approval screen, which the user can change. A sponsored transaction gets a fee of 0. A multisig transaction keeps the fee and nonce it carries.

## Example request

```typescript
import { makeUnsignedSTXTokenTransfer } from "@stacks/transactions"; // 7.x

// publicKey: the STX publicKey from getAddresses
const unsignedTx = await makeUnsignedSTXTokenTransfer({
  recipient: "SP3TB3AJ0XMZ9S6CGY2CQ6R06H1Z6DJQ1SH15ZP2H",
  amount: 1000000n, // micro-STX
  publicKey,
  network: "mainnet",
});

try {
  const response = await window.LeatherProvider.request("stx_signTransaction", {
    transaction: unsignedTx.serialize(),
  });

  console.log("Signed transaction:", response.result.transaction);
} catch (error) {
  console.log("Request error:", error.error.code, error.error.message);
}
```

## Example response

```json
{
  "jsonrpc": "2.0",
  "id": "4e7c2b1a-9d3f-4a6e-8b5c-0f1e2d3c4b5a",
  "result": {
    "transaction": "<signed transaction hex>",
    "txHex": "<signed transaction hex>"
  }
}
```

`transaction` and `txHex` carry the same signed hex.

## Errors

| Code     | Message                                                                 | When                                |
| -------- | ----------------------------------------------------------------------- | ----------------------------------- |
| `16`     | `Wallet no longer available. Reconnect the app to an available wallet.` | The origin is not connected         |
| `-32602` | Parameter validation details                                            | A parameter fails validation        |
| `-32600` | `Error signing transaction`                                             | Leather cannot sign the transaction |
| `4001`   | `User rejected request`                                                 | The user closes the window          |
