@hazae41/ledger
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Ledger

Private and supply-chain hardened Ledger controller for TypeScript

npm i @hazae41/ledger

Node Package 📦

Features

Current features

  • 100% TypeScript and ESM
  • No external dependencies
  • Rust-like patterns
  • No network code
  • No tracking

Usage

Get USB connector

/** Will open a popup using navigator.usb */
const device = Ledger.USB.getOrRequestDeviceOrThrow()
const connector = Ledger.USB.connectOrThrow(device)

Get address and/or uncompressed public key at path

const { address, uncompressedPublicKey } = await Ledger.Ethereum.getAddressOrThrow(connector, "44'/60'/0'/0/0")

Sign a personal message at path

const message = new TextEncoder().encode("Hello World")

const { r, s, v } = await Ledger.Ethereum.signPersonalMessageOrThrow(connector, "44'/60'/0'/0/0", message)

Sign a transaction at path

const transaction = ethers.utils.arrayify(ethers.Transaction.from({
  chainId,
  nonce,
  to,
  value,
  data
  gasLimit,
  gasPrice,
}).unsignedSerialized)

const { r, s, v } = await Ledger.Ethereum.signTransactionOrThrow(connector, "44'/60'/0'/0/0", transaction)

Package Sidebar

Install

npm i @hazae41/ledger

Weekly Downloads

4

Version

0.1.1

License

MIT

Unpacked Size

115 kB

Total Files

31

Last publish

Collaborators

  • hazae41