JSPM

@ledgerhq/hw-app-str

4.6.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1178
  • Score
    100M100P100Q117049F
  • License Apache-2.0

Ledger Hardware Wallet Stellar Application API

Package Exports

  • @ledgerhq/hw-app-str

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ledgerhq/hw-app-str) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Ledger Stellar app API

Usage

import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-u2f"; // for browser
import Str from "@ledgerhq/hw-app-str";

const getStrAppVersion = async () => {
    const transport = await Transport.create();
    const str = new Str(transport);
    const result = await str.getAppConfiguration();
    return result.version;
}
getStrAppVersion().then(v => console.log(v));

const getStrPublicKey = async () => {
  const transport = await Transport.create();
  const str = new Str(transport);
  const result = await str.getPublicKey("44'/148'/0'");
  return result.publicKey;
};
getStrPublicKey().then(pk => console.log(pk));

const signStrTransaction = async () => {
  const transaction = ...;
  const transport = await Transport.create();
  const str = new Str(transport);
  const result = await str.signTransaction("44'/148'/0'", transaction.signatureBase());
  
  // add signature to transaction
  const keyPair = StellarSdk.Keypair.fromPublicKey(publicKey);
  const hint = keyPair.signatureHint();
  const decorated = new StellarSdk.xdr.DecoratedSignature({hint: hint, signature: signature});
  transaction.signatures.push(decorated);
  
  return transaction;
}
signStrTransaction().then(s => console.log(s.toString('hex')));

Github, API Doc, Ledger Devs Slack