0.1.0 • Published 2 months ago

@blooo/hw-app-klaytn v0.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

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 device
  • scrambleKey. 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 index
  • display 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 Methods

Sign a Klaytn transaction. Here is a list of all the signing methods supported:

  • signLegacyTransaction
  • signValueTransfer
  • signValueTransferMemo
  • signSmartContractDeploy
  • signSmartContractExecution
  • signCancel
  • signFeeDelegatedValueTransfer
  • signFeeDelegatedValueTransferMemo
  • signFeeDelegatedSmartContractDeploy
  • signFeeDelegatedSmartContractExecution
  • signFeeDelegatedCancel
  • signFeeDelegatedValueTransferWithRatio
  • signFeeDelegatedValueTransferMemoWithRatio
  • signFeeDelegatedSmartContractDeployWithRatio
  • signFeeDelegatedSmartContractExecutionWithRatio
  • signFeeDelegatedCancelWithRatio

Each of them take exactly the same parameters.

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