跳到主要内容

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 // 错误码
}
}