@codewritz/herajs-ledger-hw-app-aergo
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Ledger Hardware Wallet Aergo JavaScript bindings

npm

How to use

npm install --save @herajs/ledger-hw-app-aergo

Getting address and signing transaction

import LedgerAppAergo from '@herajs/ledger-hw-app-aergo';
// Pick a transport. See https://github.com/LedgerHQ/ledgerjs
import Transport from '@ledgerhq/hw-transport-node-hid';
import AergoClient, { Tx } from '@herajs/client';

async () => {
    const aergo = new AergoClient();
    const transport = await Transport.create(3000, 1500);
    const app = new LedgerAppAergo(transport);
    const path = "m/44'/441'/0'/0/" + i;
    const address = await app.getWalletAddress(path);
    const tx = {
        from: address,
        to: address,
        chainIdHash: await aergo.getChainIdHash(),
        type: Tx.Type.TRANSFER,
        nonce: await aergo.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 aergo.sendSignedTransaction(tx);
    const txReceipt = await aergo.waitForTransactionReceipt(txHash); // { status: 'SUCCESS', blockno: number, ... }
}()

Readme

Keywords

none

Package Sidebar

Install

npm i @codewritz/herajs-ledger-hw-app-aergo

Weekly Downloads

1

Version

2.0.3

License

MIT

Unpacked Size

151 kB

Total Files

14

Last publish

Collaborators

  • codewritz