npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hw-app-iota

v0.6.5

Published

Ledger Hardware Wallet IOTA Application API

Downloads

32

Readme

hw-app-iota

GitHub License NPM Version Actions Status

JS Library for communication with Ledger Hardware Wallets and the IOTA Ledger Application.

Examples

Basic example

import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-u2f"; // for browser
import Iota from 'hw-app-iota';

const getAddress = async () => {
  const transport = await Transport.create();
  const iota = new Iota(transport);
  await iota.setActiveSeed("44'/4218'/0'/0'");
  return await iota.getAddress(0, {checksum: true});
};

getAddress().then(a => console.log(a));

Transaction example

import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-u2f"; // for browser
import Iota from 'hw-app-iota';

const prepareTransfers = async () => {
  const transport = await Transport.create();
  const iota = new Iota(transport);
  await iota.setActiveSeed("44'/4218'/0'/0'");

  const transfers = [{
    address: 'ANADDRESS',
    value: 10000,
    tag: 'ATAG'
  }];
  const inputs = [{
    address: 'INPUTADDRESS',
    balance: 10000,
    keyIndex: 4
  }];
  return await iota.prepareTransfers(transfers, inputs);
};

prepareTransfers().then(t => console.log(t));

See also

API Reference

hw-app-iota~Iota

Class for the interaction with the Ledger IOTA application.

iota.setActiveSeed(path, [security])

Prepares the IOTA seed to be used for subsequent calls.

| Param | Type | Default | Description | | --- | --- | --- | --- | | path | String | | String representation of the BIP32 path. At most 5 levels. | | [security] | Integer | 2 | IOTA security level to use |

Example

iota.setActiveSeed("44'/4218'/0'/0'", 2);

iota.getAddress(index, [options]) ⇒ Promise.<String>

Generates an address index-based. The result depends on the initalized seed and security level.

Returns: Promise.<String> - Tryte-encoded address

| Param | Type | Default | Description | | --- | --- | --- | --- | | index | Integer | | Index of the address | | [options] | Object | | | | [options.checksum] | Boolean | false | Append 9 tryte checksum | | [options.display] | Boolean | false | Display generated address on display |

Example

iota.getAddress(0, { checksum: true });

iota.prepareTransfers(transfers, inputs, [remainder], [now]) ⇒ Promise.<Array.<String>>

Prepares the array of raw transaction data (trytes) by generating a bundle and signing the inputs.

Returns: Promise.<Array.<String>> - Transaction trytes of 2673 trytes per transaction

| Param | Type | Default | Description | | --- | --- | --- | --- | | transfers | Array.<Object> | | Transfer objects | | transfers[].address | String | | Tryte-encoded address of recipient, with or without the 9 tryte checksum | | transfers[].value | Integer | | Value to be transferred | | transfers[].tag | String | | Tryte-encoded tag. Maximum value is 27 trytes. | | inputs | Array.<Object> | | Inputs used for funding the transfer | | inputs[].address | String | | Tryte-encoded source address, with or without the 9 tryte checksum | | inputs[].balance | Integer | | Balance of that input | | inputs[].keyIndex | String | | Index of the address | | [inputs[].tags] | Array.<String> | | Tryte-encoded tags, one for each security level. | | [remainder] | Object | | Destination for sending the remainder value (of the inputs) to. | | remainder.address | String | | Tryte-encoded address, with or without the 9 tryte checksum | | remainder.keyIndex | Integer | | Index of the address | | [remainder.tag] | String | | Tryte-encoded tag. Maximum value is 27 trytes. | | [now] | function | Date.now() | Function to get the milliseconds since the UNIX epoch for timestamps. |

iota.getAppVersion() ⇒ Promise.<String>

Retrieves version information about the installed application from the device.

Returns: Promise.<String> - Semantic Version string (i.e. MAJOR.MINOR.PATCH)

iota.getAppMaxBundleSize() ⇒ Promise.<Integer>

Retrieves the largest supported number of transactions (including meta transactions) in one transfer bundle from the device.

Returns: Promise.<Integer> - Maximum bundle size