Github
@blooo/hw-app-klaytn
Ledger Hardware Wallet Klaytn JavaScript bindings.
API
Table of Contents
Klaytn
Klaytn API
Parameters
transport
. A transport for sending commands to a devicescrambleKey
. A scramble key (optional, default "klaytn_default_scramble_key"
)
Examples
import Klaytn from "blooo/hw-app-klaytn";
const klaytn = new Klaytn(transport);
Basic Information methods
getVersion()
Get application version.
Examples
klaytn.getVersion().then((r) => r.version);
Returns Promise<{version: string}> version object
getAddress
Get Klaytn address (public key) for a BIP32 path.
Parameters
path
string a BIP32 path without the address indexdisplay
boolean flag to show display (default)accountIndex
number index of account address (optional, default 0
)
Examples
klaytn.getAddress("44'/8217'/0'/0/", false, 0).then((r) => r.address);
Returns Promise<{address: string, publicKey: string, chainCode: string | undefined}> an object with the address field
Transaction Signing Method
To sign a Klaytn transaction use the method: signTransaction .
Parameters
Examples
import Caver from "caver-js";
const caver = new Caver();
const accountIndex = 1;
const txn = caver.transaction.valueTransfer.create({
from: "enter address here",
to: "enter address here",
value: 1,
gasPrice: 50000000000,
gas: 300000,
nonce: 1,
chainId: 1001,
});
klaytn.signTransaction(txn, accountIndex).then((r) => r.signature);
Returns Promise<{signature: [v,r,s], signedTxn: caver transaction.}> an object with the signed transaction and signature