Library for interacting with the Ledger VITE app from the browser or Node.
import Vite from "ledgerjs-hw-app-vite";
const vite = new Vite(transport);
获取固件版本号以及 builtin token 数量。
None
const result = await vite.getAppConfig();
Returns Promise<{version: string, builtinTokenCount: Uint16}>
获取内置 token info,仅用于测试固件的代码。
index
number 内置 token index,从0开始,最大为 builtinTokenCount-1
const result = await vite.getBuiltinTokenInfo(0);
Returns Promise<{tokenId: TokenId, decimals: number, symbolAndIndex: string}>
测试 amount 展示信息的正确性,仅用于测试固件的代码。
amount
BigInttokenId
TokenId
const amountText = await vite.getTestAmountText('1234567890123456789', 'tti_5649544520544f4b454e6e40');
Returns Promise<string>
获取地址及其公钥。
accountIndex
number 账户序号,从0开始boolDisplay
boolean 是否在屏幕上显示地址
const result = await getAddress(accountIndex, false);
const result = await getAddress(accountIndex, true);
Returns Promise<{publicKey: Base64, address: Address}>
sign response account block
accountIndex
number 账户序号,从0开始height
Uint64 account block heightsendBlockHash
Hex send block hashpreviousHash?
Hex previous account block hashnonce?
Base64 nonce
const signResult = await vite.signResponseAccountBlock(0, 1, "1e3004d74382a8635b836eb8a3e34ede7c00a7a1bff0c150974c1235287ad07a", null, "4KVvCafscbA=");
Returns Promise<{blockHash: Hex, signature: Base64}>
sign request account block
accountIndex
number 账户序号,从0开始height
Uint64 account block heighttoAddress
Address to addressamount
BigInt amounttokenId
TokenId token IDdata?
Base64? datafee?
BigInt feepreviousHash?
Hex previous account block hashnonce?
Base64 nonce
const signResult = await vite.signRequestAccountBlock(0, 4, 'vite_847e1672c9a775ca0f3c3a2d3bf389ca466e5501cbecdb7107', '1000000000000000000', 'tti_5649544520544f4b454e6e40', null, null, '1e3004d74382a8635b836eb8a3e34ede7c00a7a1bff0c150974c1235287ad07a', null);
Returns Promise<{blockHash: Hex, signature: Base64}>