> For the complete documentation index, see [llms.txt](https://support.safeheron.com/help-center/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.safeheron.com/help-center/jian-ti-zhong-wen/chan-pin/bulletin-board/safeheron-api-shi-yong-mpc-qian-ming-zi-ding-yi-shu-ju.md).

# Safeheron API：使用 MPC 签名自定义数据

2021-01-20

![](https://content.gitbook.com/content/F9Tpg0Wb2oWmaDPnF8WY/blobs/P2V0PQuFwvnjLQGKR3BK/mpc%20sign%20%E5%85%AC%E5%91%8A.png)

Safeheron V1.1.4 已于 2022.01.20 正式上线，为 Safeheron 用户<mark style="background-color:green;">开放底层 MPC 签名能力</mark>，用户可根据自身需求自由启用，灵活参与更多交互。

#### 如何使用 MPC Sign?

Safeheron 用户可以灵活组装需要签名的数据 hash，通过 Safeheron API 发起 MPC Sign 交易，对数据 hash 进行 MPC 签名，实现对 Safeheron 尚未支持的区块链资产进行转账的能力， 以及与 DeFi 协议进行交互的能力。

#### ***以 ETH 为例，如何构造交易并进行签名呢？***

（1）准备交易所需数据：from, to, nonce, gasLimit, gasPrice, value, data(input)&#x20;

（2）序列化得到原始交易数据：rawTransaction = RLP（from, to, nonce, gasLimit, gasPrice, value, data）&#x20;

（3）计算原始交易数据 hash： needSignHash = sha3（rawTransaction）

&#x20;（4）对 hash 进行 MPC 签名：调用 Safeheron API 发起 MPC Sign 交易，拿到签名后的 sig&#x20;

（5）组装签名后原始交易数据：signedRawTransaction = RLP（from, to, nonce, gasLimit, gasPrice, value, data, sig）&#x20;

（6）本地计算交易 hash： txHash = sha3（signedRawTransaction）&#x20;

（7）提交交易到节点：rpc.submitTransaction（signedRawTransaction）

**欢迎升级 V1.1.4 版本，随时体验 MPC Sign。**
