跳到主要内容

polkadotGetAddress

使用要求

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

Polkadot:获取地址

获取指定的 BIP32 路径派生地址。用户需要在 Ukey Wallet 上核对并确认导出该地址。

const result = await HardwareSDK.polkadotGetAddress(
connectId,
deviceId,
params,
);

参数

可选通用参数

导出单个地址

  • path - 必需 string | Array<number>,字符串数组最小长度限制为 3更多信息
  • prefix - 必需 string,地址前缀;默认值为 nexatest
  • network - 必需 string,网络名称;默认值为 polkadot
  • showOnUKey - 可选 boolean,决定是否在设备上进行地址显示;默认值为 true

导出批量地址

  • bundle - Array 数组对象,包含 pathshowOnUKey 字段。

示例

获取第二个 Polkadot 账户的地址:

HardwareSDK.polkadotGetAddress(connectId, deviceId, {
path: "m/44'/354'/1'/0'/0'",
showOnUKey: true,
isTestnet: false,
});

批量获取多个 Polkadot 账户的地址:

HardwareSDK.polkadotGetAddress(connectId, deviceId, {
bundle: [
{ path: "m/44'/354'/3'/0'/0'" }, // 第4个派生账户路径
{ path: "m/44'/354'/4'/0'/0'" }, // 第5个派生账户路径
{ path: "m/44'/354'/5'/0'/0'" }, // 第6个派生账户路径
],
});

返回结果

只有一个公钥的结果

{
success: true,
payload: {
path: Array<number>, // 派生路径
address: string, // 返回的地址
publicKey: string, // 返回的公钥
}
}

批量地址的结果

{
success: true,
payload: [
{ path, address, publicKey }, // 第4个派生账户路径
{ path, address, publicKey }, // 第5个派生账户路径
{ path, address, publicKey }, // 第6个派生账户路径
]
}

错误

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