How to use the @ledgerhq/hw-app-eth function in @ledgerhq/hw-app-eth

To help you get started, we’ve selected a few @ledgerhq/hw-app-eth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unstoppabledomains / browseth / src / signers / ledger.ts View on Github external
public async initialize(): Promise<{app: AppEth; close(): void}> {
    if (!Ledger.allowParallel && Ledger.initialized) {
      throw new Error('another ledger wallet call is already initialized');
    }

    Ledger.initialized = true;
    const transport = await Ledger.Transport.create();

    // transport.setDebugMode(true);
    return {
      app: new AppEth(transport),
      close: () => {
        Ledger.initialized = false;
        transport.close();
      },
    };
  }
github LedgerHQ / ledgerjs / packages / web3-subprovider / src / index.js View on Github external
async function signTransaction(txData) {
    const path = addressToPathMap[txData.from.toLowerCase()];
    if (!path) throw new Error("address unknown '" + txData.from + "'");
    const transport = await getTransport();
    try {
      const eth = new AppEth(transport);
      const tx = new EthereumTx(txData);

      // Set the EIP155 bits
      tx.raw[6] = Buffer.from([networkId]); // v
      tx.raw[7] = Buffer.from([]); // r
      tx.raw[8] = Buffer.from([]); // s

      // Pass hex-rlp to ledger for signing
      const result = await eth.signTransaction(
        path,
        tx.serialize().toString("hex")
      );

      // Store signature in transaction
      tx.v = Buffer.from(result.v, "hex");
      tx.r = Buffer.from(result.r, "hex");
github urbit / bridge / src / views / Ledger.js View on Github external
async pollDevice() {
    const { setWallet, setWalletHdPath } = this.props;
    const { hdpath } = this.state;

    const transport = await Transport.create();
    const eth = new Eth(transport);
    const path = chopHdPrefix(hdpath);

    eth.getAddress(path, false, true).then(
      info => {
        const publicKey = Buffer.from(info.publicKey, 'hex');
        const chainCode = Buffer.from(info.chainCode, 'hex');
        const pub = secp256k1.publicKeyConvert(publicKey, true);
        const hd = bip32.fromPublicKey(pub, chainCode);
        setWallet(Maybe.Just(hd));
        setWalletHdPath(addHdPrefix(hdpath));
      },
      _ => {
        setWallet(Maybe.Nothing());
      }
    );
  }
github LedgerHQ / ledgerjs / packages / example-browser / index.js View on Github external
onGetLedgerEthereumAddress = async () => {
    try {
      this.setState({ error: null });
      const transport = await TransportU2F.create();
      const btc = new Eth(transport);
      const { address } = await btc.getAddress("44'/60'/0'/0'/0");
      this.setState({ address });
    } catch (error) {
      this.setState({ error });
    }
  };
  render() {
github MyEtherWallet / MyEtherWallet / src / wallets / hardware / ledger / ledgerWallet.js View on Github external
async getAppConfig() {
    const transport = await this.getTransport();
    try {
      const eth = new Ledger(transport);
      const appConfig = await eth.getAppConfiguration();
      return appConfig;
    } catch (e) {
      throw e;
    } finally {
      transport
        .close()
        .then(() => {
          this.connectionOpened = false;
        })
        .catch(error => {
          throw error;
        });
    }
  }
github floating / frame / app / flex / ledger / index.js View on Github external
constructor (device, emit) {
    this.device = device
    this.id = this.device.id
    this.eth = new AppEth(device)
    this.emit = emit
    this.setup()
  }
github hubiinetwork / hubii-core / src / utils / ledger / comms.js View on Github external
export const newEth = (transport) => new Eth(transport);
github MyEtherWallet / MyEtherWallet / src / wallets / hardware / ledger / ledgerWallet.js View on Github external
async _signPersonalMessage(msgData) {
    const path = await this.checkIfKnownAddress(msgData);
    const transport = await this.getTransport();
    try {
      const thisMessage = msgData.data ? msgData.data : msgData;
      const eth = new Ledger(transport);
      const result = await eth.signPersonalMessage(
        path,
        Buffer.from(thisMessage).toString('hex')
      );
      const v = parseInt(result.v, 10) - 27;
      let vHex = v.toString(16);
      if (vHex.length < 2) {
        vHex = `0${v}`;
      }
      return `0x${result.r}${result.s}${vHex}`;
    } finally {
      transport
        .close()
        .then(() => {
          this.connectionOpened = false;
        })

@ledgerhq/hw-app-eth

Ledger Hardware Wallet Ethereum Application API

MIT
Latest version published 5 days ago

Package Health Score

84 / 100
Full package analysis