@meey-sdk-js/meey-ledger-app
TypeScript icon, indicating that this package has built-in type declarations

0.3.6 • Public • Published

#Meey Ledger App JavaScript bindings

npm

How to use

npm install --save @meey-sdk-js/meey-pedger-app

Getting address and signing transaction

import MeeyLedgerApp from '@meey-sdk-js/meey-ledger-app';
// Pick a transport. See https://github.com/LedgerHQ/ledgerjs
import Transport from '@ledgerhq/hw-transport-node-hid';
import MeeyClient, { Tx } from '@meey-sdk-js/client';

async () => {
    const meey = new MeeyClient();
    const transport = await Transport.create(3000, 1500);
    const app = new MeeyLedgerApp(transport);
    const path = "m/44'/441'/0'/0/" + i;
    const address = await app.getWalletAddress(path);
    const tx = {
        from: address,
        to: address,
        chainIdHash: await meey.getChainIdHash(),
        type: Tx.Type.TRANSFER,
        nonce: await meey.getNonce(address) + 1,
        limit: 100000,
        nonce: 1,
    };
    const result = await app.signTransaction(tx); // { hash, signature }
    tx.sign = result.signature;
    tx.hash = await hashTransaction(tx, 'bytes');
    const txHash = await meey.sendSignedTransaction(tx);
    const txReceipt = await meey.waitForTransactionReceipt(txHash); // { status: 'SUCCESS', blockno: number, ... }
}()

Readme

Keywords

none

Package Sidebar

Install

npm i @meey-sdk-js/meey-ledger-app

Weekly Downloads

1

Version

0.3.6

License

MIT

Unpacked Size

245 kB

Total Files

16

Last publish

Collaborators

  • giactan