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

# stx\_signTransaction

You can use the `stx_signTransaction` method to request the signature of any hex-encoded Stacks transaction from your user's Stacks wallet address.

<table><thead><tr><th width="200">Request parameters</th><th>Description</th></tr></thead><tbody><tr><td><code>transaction</code></td><td>a hex-encoded string representing the  Stacks transaction to sign </td></tr><tr><td><code>broadcast</code><br>(<span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> optional)</td><td>a boolean flag that specifies whether to broadcast the signed transaction after signature. Defaults to <code>TRUE</code></td></tr></tbody></table>

You can use any Stacks library to construct these transaction. See examples using helpers from the `@stacks/transactions` package

```typescript
    import {
       makeUnsignedContractCall,
       makeUnsignedContractDeploy,
       makeUnsignedSTXTokenTransfer,
       uintCV,
     } from "@stacks/transactions";
    import { request } from "sats-connect";

    //contract call transaction   
const transaction = await makeUnsignedContractCall({
      fee: 3000,
      anchorMode: "onChainOnly",
      contractAddress: "SP21YTSM60CAY6D011EZVEVNKXVW8FVZE198XEFFP",
      contractName: "pox-fast-pool-v2",
      functionName: "set-stx-buffer",
      functionArgs: [uintCV(1)],
      publicKey: props.publicKey,
    });
    try {
      const response = await request("stx_signTransaction", {
        transaction: uint8ArrayToHex(transaction.serialize()),
      });
      if (response.status === "success") {
        console.log(response.result.transaction);
      } else {
        alert(errorMessage);
        console.error(response.error);
      }
    } catch (error) {
      alert(errorMessage);
      console.error(error);

//token transfer transaction 
    const transaction = await makeUnsignedSTXTokenTransfer({
      anchorMode: "any",
      fee: 3000,
      recipient: "SP2FFKDKR122BZWS7GDPFWC0J0FK4WMW5NPQ0Z21M", // account 4
      amount: 1000,
      publicKey: props.publicKey,
    });
    try {
      const response = await request("stx_signTransaction", {
        transaction: uint8ArrayToHex(transaction.serialize()),
      });
      if (response.status === "success") {
        console.log(response.result.transaction);
      } else {
        alert(errorMessage);
        console.error(response.error);
      }
    } catch (error) {
      alert(errorMessage);
      console.error(error);
    }


//contract deployment transaction 
    const transaction = await makeUnsignedContractDeploy({
      anchorMode: "any",
      contractName: "my-contract",
      codeBody: code,
      fee: 3000,
      publicKey: props.publicKey,
    });
    try {
      const response = await request("stx_signTransaction", {
        transaction: uint8ArrayToHex(transaction.serialize()),
      });
      if (response.status === "success") {
        console.log(response.result.transaction);
      } else {
        alert(errorMessage);
        console.error(response.error);
      }
    } catch (error) {
      alert(errorMessage);
      console.error(error);
    }
```

The above request examples will ask the wallet to:

* sign a contract call transaction
* sign a token transfer request&#x20;
* sign a contract deployment transaction

The user will see a Stacks transaction signing request prompt in the wallet. Xverse browser extension UI shown as example for a token transfer:\
\
![](/files/MIgnOlaJEabH6rtAY8jW)

The transaction will be signed and broadcasted upon user approval.

The `stx_signTransaction` method returns a Promise that resolves to the `SignTransactionResult` object:

<table><thead><tr><th width="162">Property</th><th>Description</th></tr></thead><tbody><tr><td><code>transaction</code></td><td>a hex-encoded string representing the transaction signed</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xverse.app/sats-connect/stacks-methods/stx_signtransaction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
