@ledgerhq/hw-app-eth
Ledger Hardware Wallet Ethereum Application API
Last updated a day ago by gre .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @ledgerhq/hw-app-eth 
SYNC missed versions from official npm registry.

Github, Ledger Devs Slack

@ledgerhq/hw-app-eth

Ledger Hardware Wallet ETH JavaScript bindings.

API

Table of Contents

byContractAddress

Retrieve the token information by a given contract address if any

Parameters

Returns TokenInfo?

list

list all the ERC20 tokens informations

Returns Array<TokenInfo>

Eth

Ethereum API

Parameters

  • transport Transport<any>
  • scrambleKey string (optional, default "w0w")

Examples

import Eth from "@ledgerhq/hw-app-eth";
const eth = new Eth(transport)

getAddress

get Ethereum address for a given BIP 32 path.

Parameters
Examples
eth.getAddress("44'/60'/0'/0/0").then(o => o.address)

Returns Promise<{publicKey: string, address: string, chainCode: string?}> an object with a publicKey, address and (optionally) chainCode

provideERC20TokenInformation

This commands provides a trusted description of an ERC 20 token to associate a contract address with a ticker and number of decimals.

It shall be run immediately before performing a transaction involving a contract calling this contract address to display the proper token information to the user if necessary.

Parameters
  • info any : a blob from "erc20.js" utilities that contains all token information.
    • info.data
Examples
import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20"
const zrxInfo = byContractAddress("0xe41d2489571d322189246dafa5ebde1f4699f498")
if (zrxInfo) await appEth.provideERC20TokenInformation(zrxInfo)
const signed = await appEth.signTransaction(path, rawTxHex)

Returns Promise<boolean>

signTransaction

You can sign a transaction and retrieve v, r, s given the raw transaction and the BIP 32 path of the account to sign

Parameters
Examples
eth.signTransaction("44'/60'/0'/0/0", "e8018504e3b292008252089428ee52a8f3d6e5d15f8b131996950d7f296c7952872bd72a2487400080").then(result => ...)

Returns Promise<{s: string, v: string, r: string}>

getAppConfiguration

Returns Promise<{arbitraryDataEnabled: number, erc20ProvisioningNecessary: number, starkEnabled: number, starkv2Supported: number, version: string}>

signPersonalMessage

You can sign a message according to eth_sign RPC call and retrieve v, r, s given the message and the BIP 32 path of the account to sign.

Parameters
Examples
eth.signPersonalMessage("44'/60'/0'/0/0", Buffer.from("test").toString("hex")).then(result => {
var v = result['v'] - 27;
v = v.toString(16);
if (v.length < 2) {
v = "0" + v;
}
console.log("Signature 0x" + result['r'] + result['s'] + v);
})

Returns Promise<{v: number, s: string, r: string}>

signEIP712HashedMessage

Sign a prepared message following web3.eth.signTypedData specification. The host computes the domain separator and hashStruct(message)

Parameters
Examples
eth.signEIP712HashedMessage("44'/60'/0'/0/0", Buffer.from("0101010101010101010101010101010101010101010101010101010101010101").toString("hex"), Buffer.from("0202020202020202020202020202020202020202020202020202020202020202").toString("hex")).then(result => {
var v = result['v'] - 27;
v = v.toString(16);
if (v.length < 2) {
v = "0" + v;
}
console.log("Signature 0x" + result['r'] + result['s'] + v);
})

Returns Promise<{v: number, s: string, r: string}>

starkGetPublicKey

get Stark public key for a given BIP 32 path.

Parameters

Returns Promise<Buffer> the Stark public key

starkSignOrder

sign a Stark order

Parameters
  • path string a path in BIP 32 format
  • sourceTokenAddress string?
  • sourceQuantization BigNumber quantization used for the source token
  • destinationTokenAddress string?
  • destinationQuantization BigNumber quantization used for the destination token
  • sourceVault number ID of the source vault
  • destinationVault number ID of the destination vault
  • amountSell BigNumber amount to sell
  • amountBuy BigNumber amount to buy
  • nonce number transaction nonce
  • timestamp number transaction validity timestamp

Returns Promise<Buffer> the signature

starkSignOrder_v2

sign a Stark order using the Starkex V2 protocol

Parameters
  • path string a path in BIP 32 format
  • sourceTokenAddress string?
  • sourceQuantizationType StarkQuantizationType quantization type used for the source token
  • sourceQuantization BigNumber?
  • sourceMintableBlobOrTokenId BigNumber?
  • destinationTokenAddress string?
  • destinationQuantizationType StarkQuantizationType quantization type used for the destination token
  • destinationQuantization BigNumber?
  • destinationMintableBlobOrTokenId BigNumber?
  • sourceVault number ID of the source vault
  • destinationVault number ID of the destination vault
  • amountSell BigNumber amount to sell
  • amountBuy BigNumber amount to buy
  • nonce number transaction nonce
  • timestamp number transaction validity timestamp

Returns Promise<Buffer> the signature

starkSignTransfer

sign a Stark transfer

Parameters
  • path string a path in BIP 32 format
  • transferTokenAddress string?
  • transferQuantization BigNumber quantization used for the token to be transferred
  • targetPublicKey string target Stark public key
  • sourceVault number ID of the source vault
  • destinationVault number ID of the destination vault
  • amountTransfer BigNumber amount to transfer
  • nonce number transaction nonce
  • timestamp number transaction validity timestamp

Returns Promise<Buffer> the signature

starkSignTransfer_v2

sign a Stark transfer or conditional transfer using the Starkex V2 protocol

Parameters
  • path string a path in BIP 32 format
  • transferTokenAddress string?
  • transferQuantizationType StarkQuantizationType quantization type used for the token to be transferred
  • transferQuantization BigNumber?
  • transferMintableBlobOrTokenId BigNumber?
  • targetPublicKey string target Stark public key
  • sourceVault number ID of the source vault
  • destinationVault number ID of the destination vault
  • amountTransfer BigNumber amount to transfer
  • nonce number transaction nonce
  • timestamp number transaction validity timestamp
  • conditionalTransferAddress string?
  • conditionalTransferFact BigNumber?

Returns Promise<Buffer> the signature

starkProvideQuantum

provide quantization information before singing a deposit or withdrawal Stark powered contract call

It shall be run following a provideERC20TokenInformation call for the given contract

Parameters
  • operationContract string? contract address of the token to be transferred (not present for ETH)
  • operationQuantization BigNumber quantization used for the token to be transferred

Returns Promise<boolean>

starkProvideQuantum_v2

provide quantization information before singing a deposit or withdrawal Stark powered contract call using the Starkex V2 protocol

It shall be run following a provideERC20TokenInformation call for the given contract

Parameters
  • operationContract string? contract address of the token to be transferred (not present for ETH)
  • operationQuantizationType StarkQuantizationType quantization type of the token to be transferred
  • operationQuantization BigNumber?
  • operationMintableBlobOrTokenId BigNumber?

Returns Promise<boolean>

starkUnsafeSign

sign the given hash over the Stark curve It is intended for speed of execution in case an unknown Stark model is pushed and should be avoided as much as possible.

Parameters
  • path string a path in BIP 32 format
  • hash string hexadecimal hash to sign

Returns Promise<Buffer> the signature

eth2GetPublicKey

get an Ethereum 2 BLS-12 381 public key for a given BIP 32 path.

Parameters
Examples
eth.eth2GetPublicKey("12381/3600/0/0").then(o => o.publicKey)

Returns Promise<{publicKey: string}> an object with a publicKey

eth2SetWithdrawalIndex

Set the index of a Withdrawal key used as withdrawal credentials in an ETH 2 deposit contract call signature

It shall be run before the ETH 2 deposit transaction is signed. If not called, the index is set to 0

Parameters
  • withdrawalIndex number index path in the EIP 2334 path m/12381/3600/withdrawalIndex/0

Returns Promise<boolean> True if the method was executed successfully

Current Tags

  • 5.33.1-alpha.3                                ...           canary (2 months ago)
  • 5.41.0                                ...           latest (a day ago)

230 Versions

  • 5.41.0                                ...           a day ago
  • 5.40.0                                ...           6 days ago
  • 5.39.1                                ...           8 days ago
  • 5.39.0                                ...           12 days ago
  • 5.38.0                                ...           21 days ago
  • 5.37.0                                ...           a month ago
  • 5.36.0                                ...           a month ago
  • 5.35.1                                ...           2 months ago
  • 5.35.0                                ...           2 months ago
  • 5.34.1                                ...           2 months ago
  • 5.34.0                                ...           2 months ago
  • 5.33.1-alpha.3                                ...           2 months ago
  • 5.33.0                                ...           2 months ago
  • 5.32.1                                ...           2 months ago
  • 5.32.0                                ...           2 months ago
  • 5.31.0                                ...           2 months ago
  • 5.30.0                                ...           2 months ago
  • 5.29.0                                ...           2 months ago
  • 5.26.1-alpha.2                                ...           2 months ago
  • 5.28.0                                ...           3 months ago
  • 5.27.2                                ...           3 months ago
  • 5.27.1                                ...           3 months ago
  • 5.27.0                                ...           3 months ago
  • 5.26.0                                ...           4 months ago
  • 5.25.3                                ...           4 months ago
  • 5.25.2                                ...           4 months ago
  • 5.25.1                                ...           4 months ago
  • 5.25.0                                ...           4 months ago
  • 5.24.1-alpha.5                                ...           4 months ago
  • 5.24.1-alpha.4                                ...           4 months ago
  • 5.24.1-alpha.2                                ...           4 months ago
  • 5.24.1-alpha.1                                ...           4 months ago
  • 5.24.1-alpha.0                                ...           4 months ago
  • 5.24.0                                ...           4 months ago
  • 5.23.0                                ...           5 months ago
  • 5.22.0                                ...           6 months ago
  • 5.21.0                                ...           6 months ago
  • 5.20.0                                ...           6 months ago
  • 5.19.1                                ...           6 months ago
  • 5.19.0                                ...           7 months ago
  • 5.18.0                                ...           7 months ago
  • 5.17.0                                ...           7 months ago
  • 5.16.0                                ...           8 months ago
  • 5.15.0                                ...           9 months ago
  • 5.14.0                                ...           9 months ago
  • 5.13.1                                ...           9 months ago
  • 5.13.0                                ...           10 months ago
  • 5.12.2                                ...           10 months ago
  • 5.12.1                                ...           10 months ago
  • 5.12.0                                ...           10 months ago
  • 5.12.0-alpha.6                                ...           10 months ago
  • 5.11.0                                ...           a year ago
  • 5.9.0                                ...           a year ago
  • 5.8.0                                ...           a year ago
  • 5.7.0                                ...           a year ago
  • 5.6.0                                ...           a year ago
  • 5.5.0                                ...           a year ago
  • 5.4.2                                ...           a year ago
  • 5.3.0                                ...           a year ago
  • 5.2.0                                ...           a year ago
  • 5.1.1-alpha.2                                ...           a year ago
  • 5.1.0                                ...           a year ago
  • 5.0.0                                ...           a year ago
  • 5.0.0-rc.4                                ...           a year ago
  • 5.0.0-babel7.4                                ...           a year ago
  • 4.78.0                                ...           a year ago
  • 5.0.0-babel7.3                                ...           a year ago
  • 5.0.0-babel7.1                                ...           a year ago
  • 4.77.0                                ...           a year ago
  • 5.0.0-alpha.7                                ...           a year ago
  • 4.76.0                                ...           a year ago
  • 4.74.3-alpha.6                                ...           a year ago
  • 5.0.0-alpha.5                                ...           a year ago
  • 5.0.0-alpha.4                                ...           a year ago
  • 5.0.0-alpha.3                                ...           a year ago
  • 4.74.2                                ...           a year ago
  • 4.74.1                                ...           a year ago
  • 4.74.0                                ...           a year ago
  • 4.73.7                                ...           a year ago
  • 4.73.5                                ...           a year ago
  • 4.73.4                                ...           a year ago
  • 4.73.3                                ...           a year ago
  • 4.73.2                                ...           a year ago
  • 4.73.1                                ...           a year ago
  • 4.73.0                                ...           a year ago
  • 4.72.2                                ...           a year ago
  • 4.72.1                                ...           a year ago
  • 4.72.0                                ...           a year ago
  • 4.71.0                                ...           a year ago
  • 4.70.3                                ...           a year ago
  • 4.70.2                                ...           a year ago
  • 4.70.0                                ...           a year ago
  • 4.69.3-alpha.1                                ...           a year ago
  • 4.69.2                                ...           a year ago
  • 4.69.1                                ...           a year ago
  • 4.69.0                                ...           a year ago
  • 4.68.4                                ...           a year ago
  • 4.68.2                                ...           2 years ago
  • 4.68.1                                ...           2 years ago
  • 4.68.0                                ...           2 years ago
  • 4.67.0                                ...           2 years ago
  • 4.66.0                                ...           2 years ago
  • 4.64.1                                ...           2 years ago
  • 4.64.0                                ...           2 years ago
  • 4.63.2                                ...           2 years ago
  • 4.63.1                                ...           2 years ago
  • 4.62.0                                ...           2 years ago
  • 4.61.0                                ...           2 years ago
  • 4.60.3                                ...           2 years ago
  • 4.60.2                                ...           2 years ago
  • 4.60.0                                ...           2 years ago
  • 4.59.1-alpha.2                                ...           2 years ago
  • 4.58.0                                ...           2 years ago
  • 4.57.0                                ...           2 years ago
  • 4.14.0-alpha.6c128343                                ...           2 years ago
  • 4.56.0                                ...           2 years ago
  • 4.55.1-alpha.2                                ...           2 years ago
  • 4.55.0                                ...           2 years ago
  • 4.54.0                                ...           2 years ago
  • 4.53.0                                ...           2 years ago
  • 4.52.3-alpha.2                                ...           2 years ago
  • 4.52.0                                ...           2 years ago
  • 4.50.0                                ...           2 years ago
  • 4.48.0                                ...           2 years ago
  • 4.47.0                                ...           2 years ago
  • 4.46.1                                ...           2 years ago
  • 4.46.0                                ...           2 years ago
  • 4.45.0                                ...           2 years ago
  • 4.44.2                                ...           2 years ago
  • 4.44.0                                ...           2 years ago
  • 4.43.1-alpha.0                                ...           2 years ago
  • 4.43.0                                ...           2 years ago
  • 4.41.1                                ...           2 years ago
  • 4.41.0                                ...           2 years ago
  • 4.39.0                                ...           2 years ago
  • 4.38.6                                ...           2 years ago
  • 4.38.0                                ...           2 years ago
  • 4.36.2                                ...           2 years ago
  • 4.37.0                                ...           2 years ago
  • 4.35.1-beta.28                                ...           2 years ago
  • 4.37.0-beta.2b8718d2                                ...           2 years ago
  • 4.36.0                                ...           2 years ago
  • 4.35.0                                ...           2 years ago
  • 4.32.0                                ...           2 years ago
  • 4.28.0-beta.927e2da4                                ...           2 years ago
  • 4.26.0-beta.33b393bd                                ...           2 years ago
  • 4.26.0-beta.0a38903c                                ...           2 years ago
  • 4.26.0-beta.ecce9a72                                ...           2 years ago
  • 4.26.0-beta.61c8ac0d                                ...           2 years ago
  • 4.26.0-beta.65ce4393                                ...           2 years ago
  • 4.26.0-beta.9614a692                                ...           2 years ago
  • 4.26.0-beta.ad904ce3                                ...           2 years ago
  • 4.26.0-beta.ebeb3540                                ...           2 years ago
  • 4.24.0                                ...           2 years ago
  • 4.24.0-beta.aeaefa0e                                ...           2 years ago
  • 4.23.0                                ...           2 years ago
  • 4.22.0-beta.a1987cb3                                ...           2 years ago
  • 4.22.0-beta.96c1e355                                ...           2 years ago
  • 4.22.0-beta.ae6f5c51                                ...           3 years ago
  • 4.21.0                                ...           3 years ago
  • 4.21.0-beta.9cf3bfae                                ...           3 years ago
  • 4.21.0-beta.12bfb9a2                                ...           3 years ago
  • 4.19.0                                ...           3 years ago
  • 4.15.0                                ...           3 years ago
  • 4.14.0                                ...           3 years ago
  • 4.13.0                                ...           3 years ago
  • 4.12.0-beta.b14e7f27                                ...           3 years ago
  • 4.12.0-beta.87012289                                ...           3 years ago
  • 4.12.0-beta.a4c9b217                                ...           3 years ago
  • 4.12.0-beta.7be0b960                                ...           3 years ago
  • 4.12.0-beta.e285238a                                ...           3 years ago
  • 4.12.0-beta.a9ddcef0                                ...           3 years ago
  • 4.12.0                                ...           3 years ago
  • 4.12.0-beta.fd04ab6f                                ...           3 years ago
  • 4.7.3                                ...           3 years ago
  • 4.7.0                                ...           3 years ago
  • 4.8.0-rc1.1b178f67                                ...           3 years ago
  • 4.8.0-beta.1b178f67                                ...           3 years ago
  • 4.8.0-beta.b178a6cf                                ...           3 years ago
  • 4.8.0-beta.37537633                                ...           3 years ago
  • 4.6.0                                ...           3 years ago
  • 4.6.0-beta.4dd99136                                ...           3 years ago
  • 4.6.0-beta.5109e524                                ...           3 years ago
  • 4.3.0                                ...           3 years ago
  • 4.3.0-beta.f8165b69                                ...           3 years ago
  • 4.3.0-beta.bff98635                                ...           3 years ago
  • 4.3.0-beta.4bae85a3                                ...           3 years ago
  • 4.3.0-beta.42bb5526                                ...           3 years ago
  • 4.3.0-beta.c3ce76cd                                ...           3 years ago
  • 4.3.0-beta.954e9e07                                ...           3 years ago
  • 4.3.0-beta.589ba3c6                                ...           3 years ago
  • 4.3.0-beta.79913151                                ...           3 years ago
  • 4.3.0-beta.d226ed3b                                ...           3 years ago
  • 4.2.0                                ...           3 years ago
  • 4.2.0-beta.6b217210                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.1.0-beta.25cc60f6                                ...           3 years ago
  • 3.1.0-beta.da8a3a7f                                ...           3 years ago
  • 3.1.0-beta.7e23155d                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.2.0                                ...           3 years ago
  • 2.2.0-beta.54c3d0df                                ...           3 years ago
  • 2.2.0-beta.99d71ce2                                ...           3 years ago
  • 2.2.0-beta.9d29a5c6                                ...           3 years ago
  • 2.1.3                                ...           3 years ago
  • 2.1.2                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.5                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.2.0-beta.6cd06d6f                                ...           3 years ago
  • 1.2.0-beta.ae9d68f7                                ...           3 years ago
  • 1.2.0-beta.df091f88                                ...           3 years ago
  • 1.2.0-beta.7172f590                                ...           3 years ago
  • 1.2.0-beta.5f7fbb68                                ...           3 years ago
  • 1.2.0-beta.ee36acc9                                ...           3 years ago
  • 1.2.0-beta.ffc162fd                                ...           3 years ago
  • 1.2.0-beta.10b44916                                ...           3 years ago
  • 1.2.0-beta.b4ba11b7                                ...           3 years ago
  • 1.1.2-beta.068e2a14                                ...           3 years ago
  • 1.1.1-beta.068e2a14                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.1.0-beta.4775db4c                                ...           3 years ago
  • 1.1.0-beta.b03dab45                                ...           3 years ago
  • 1.1.0-beta.9f0d7158                                ...           3 years ago
  • 1.1.0-beta.cd0f5eae                                ...           3 years ago
  • 1.1.0-beta.e6f42082                                ...           3 years ago
  • 1.1.0-beta.8cc6fdd9                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
Downloads
Today 12
This Week 41
This Month 266
Last Day 23
Last Week 130
Last Month 535
Dependencies (5)
Dev Dependencies (1)
Dependents (120)

Copyright 2014 - 2016 © taobao.org |