跳到主要内容

scdoSignTransaction

使用要求

  • 固件版本要求
    • UKey Lite 24 / UKey Lite 25 / UKey Core 26: 1.1.0

SCDO:签名交易

使用指定 BIP32 路径派生的私钥对交易进行签名。

const response = await HardwareSDK.scdoSignTransaction(connectId, deviceId, {
path: "m/44'/541'/2'/0/0",
nonce: "0x1",
gasPrice: "0xd693a400",
gasLimit: "0x61a8",
to: "1S8fb92c14e7ad3c6b5f9124dc7a4b7e6a2f1c0d55",
value: "0x1e8480",
timestamp: "1700000000",
data: "0x68656c6c6f", // 可选
txType: 1, // 可选
});

参数

可选通用参数

  • path - 必需 string | Array<number>,用于签名的 BIP32 路径,字符串数组最小长度限制为 3更多信息
  • nonce - 必需 string,以十六进制文本表示的交易 nonce。
  • gasPrice - 必需 string,以十六进制文本表示的 gas 价格。
  • gasLimit - 必需 string,以十六进制文本表示的 gas 限制。
  • to - 必需 string,交易目标地址。
  • value - 必需 string,以十六进制文本表示的交易金额。
  • timestamp - 可选 string,交易时间戳信息。
  • data - 可选 string,以十六进制文本表示的交易附加数据。
  • txType - 可选 number,交易类型标识。

示例

const response = await HardwareSDK.scdoSignTransaction(connectId, deviceId, {
path: "m/44'/541'/2'/0/0",
nonce: "0x2",
gasPrice: "0xd693a400",
gasLimit: "0x61a8",
to: "1S8fb92c14e7ad3c6b5f9124dc7a4b7e6a2f1c0d55",
value: "0x1e8480",
timestamp: "1700000000",
});

返回结果

{
success: true,
payload: {
signature: string, // 签名结果
data_length: number, // 交易数据长度
path: string // 使用的 BIP32 路径
}
}

错误

{
success: false,
payload: {
error: string, // 错误消息
code: number // 错误码
}
}