> For the complete documentation index, see [llms.txt](https://support.backpack.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.backpack.exchange/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/provider-fang-fa/signtransaction-qian-ming-dan-bi-jiao-yi.md).

# SignTransaction（签名单笔交易）

[SignAndSendTransaction ](/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/provider-fang-fa/signandsendtransaction-qian-ming-bing-fa-song-jiao-yi.md)是发送交易最简单且推荐的方法。Backpack 会在签名后立即提交交易，这对用户来说更安全，同时为开发者提供更简洁的 API。

不过，应用也可以仅请求 Backpack 提供交易签名。

签名完成后，应用可使用 [web3.js ](https://solana-labs.github.io/solana-web3.js/classes/Connection.html#sendRawTransaction)的 `sendRawTransaction` 方法自行提交交易。

## **基础 URL**

```
https://backpack.app/ul/v1/signTransaction
```

## **查询字符串参数**

* `dapp_encryption_public_key`（必填）：应用端用于当前[connect](/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/provider-fang-fa/connect-lian-jie.md)（连接）会话的原始加密公钥。
* `nonce`（必填）：用于加密请求的 base58 编码随机数。
* `redirect_link`（必填）：操作完成后，Backpack 应将用户重定向至该 URI。请参阅[Specifying Redirects](/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/specifying-redirects-zhi-ding-zhong-ding-xiang.md)了解更多信息。需进行 URL 编码。
* `payload`（必填）：加密的 JSON 字符串，包含以下字段：

```json
{
  "transaction": "...", // 序列化交易，base58 编码
  "session": "...",     // 来自 connect 方法的 token
}
```

* `transaction` (必填)：Backpack 将要签名的[transaction](https://solana-labs.github.io/solana-web3.js/classes/Transaction.html)（交易），已进行序列化并使用 base58 编码。
* `session`（必填）：来自 [Connect](/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/provider-fang-fa/connect-lian-jie.md) 方法的会话 token。详见[Handling Sessions](/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/handling-sessions-hui-hua-chu-li.md)。

## **返回值**

### Approve（同意）

* `nonce`：用于加密响应的 base58 编码随机数。
* `data`：加密的 JSON 字符串。请参考[Encryption](/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/encryption-jia-mi-ji-zhi.md)部分了解如何通过共享密钥解密。加密内容以 base58 编码。

```json
// 解密后的 `data` 参数内容
{
  transaction: "...", // 已签名的序列化交易，base58 编码
}
```

**`transaction`**：已签名、序列化并以 base58 编码的交易。Backpack 不会提交此交易。应用程序可以通过 [web3.js ](https://solana-labs.github.io/solana-web3.js/classes/Connection.html#sendRawTransaction)的 `sendRawTransaction` 方法提交此交易。

### Reject（拒绝）

错误情况会以 `errorCode` 和 `errorMessage` 作为查询参数返回。

请参阅[ Errors ](/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/limitations-xian-zhi.md#errors-cuo-wu-chu-li)了解所有可能的错误代码。

```json
{
  "errorCode": "...",
  "errorMessage": "..."
}
```


---

# 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, and the optional `goal` query parameter:

```
GET https://support.backpack.exchange/support-docs/cn/qian-bao/ji-shu-wen-dang/deeplinks/provider-fang-fa/signtransaction-qian-ming-dan-bi-jiao-yi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
