tonSignMessage
使用要求
- 固件版本要求
- UKey Lite 24 / UKey Lite 25 / UKey Core 26: 1.1.0
TON:签名消息
使用指定 BIP32 路径派生的私钥对消息或交易进行签名,用户需要在 Ukey Wallet 设备上确认操作。
const response = await HardwareSDK.tonSignMessage(connectId, deviceId, {
path: "m/44'/607'/1'",
destination: "UQDr5p6Qf8xYV2wqL9mN7cT4kJ1sH3eB6aZ0uR2nP4yW8tC",
tonAmount: 25,
seqno: 2,
expireAt: Date.now() + 1000 * 60 * 30,
walletVersion: 3,
isBounceable: false,
isTestnetOnly: false,
});
参数
必需参数
path- 必需string | Array<number>,字符串数组最小长度限制为3。更多信息destination- 必需string,目标地址。tonAmount- 必需number,转账的 TON 数量。seqno- 必需number,序列号。expireAt- 必需number,消息过期的时间戳。
可选参数
walletVersion- 可选TonWalletVersion,TON 钱包版本;默认值为3。isBounceable- 可选boolean,决定消息是否可弹回;默认值为false。isTestnetOnly- 可选boolean,决定是否使用测试网;默认值为false。jettonMasterAddress- 可选string,Jetton 主合约地址。jettonAmount- 可选number,转账的 Jetton 数量。fwdFee- 可选number,Jetton 转账的转发费用。comment- 可选string,消息备注。mode- 可选number,消息模式。workchain- 可选TonWorkChain,TON 工作链。walletId- 可选number,钱包 ID。
示例
// 简单的 TON 转账示例
const response = await HardwareSDK.tonSignMessage(connectId, deviceId, {
path: "m/44'/607'/1'",
destination: "UQDr5p6Qf8xYV2wqL9mN7cT4kJ1sH3eB6aZ0uR2nP4yW8tC",
tonAmount: 25,
seqno: 2,
expireAt: Date.now() + 1000 * 60 * 30,
walletVersion: 3,
isBounceable: false,
isTestnetOnly: false,
});
// 多笔原生代币转账示例
const jettonResponse = await HardwareSDK.tonSignMessage(connectId, deviceId, {
path: "m/44'/607'/1'",
destination: "UQDr5p6Qf8xYV2wqL9mN7cT4kJ1sH3eB6aZ0uR2nP4yW8tC",
tonAmount: 25,
seqno: 2,
expireAt: Date.now() + 1000 * 60 * 30,
walletVersion: 3,
isBounceable: false,
isTestnetOnly: false,
extDestination: ["UQC7m4Lx2vR9pN6kT1yD8sF3hJ5qW0bC4eZ7uM2aX9rP6nV"],
extTonAmount: [12],
extPayload: ["48656c6c6f20554b6579"],
});
返回结果
{
success: true,
payload: {
skip_validate: boolean; // 是否跳过设备校验
signature: string; // 签名结果
signning_message: string; // 待签名消息内容
}
}
错误
{
success: false,
payload: {
error: string, // 错误消息
code: number // 错误码
}
}