0.6.5 • Published 3 years ago

hw-app-iota v0.6.5

Weekly downloads
13
License
Apache-2.0
Repository
github
Last release
3 years ago

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.

ParamTypeDefaultDescription
pathStringString representation of the BIP32 path. At most 5 levels.
securityInteger2IOTA 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

ParamTypeDefaultDescription
indexIntegerIndex of the address
optionsObject
options.checksumBooleanfalseAppend 9 tryte checksum
options.displayBooleanfalseDisplay 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

ParamTypeDefaultDescription
transfersArray.<Object>Transfer objects
transfers[].addressStringTryte-encoded address of recipient, with or without the 9 tryte checksum
transfers[].valueIntegerValue to be transferred
transfers[].tagStringTryte-encoded tag. Maximum value is 27 trytes.
inputsArray.<Object>Inputs used for funding the transfer
inputs[].addressStringTryte-encoded source address, with or without the 9 tryte checksum
inputs[].balanceIntegerBalance of that input
inputs[].keyIndexStringIndex of the address
[inputs[].tags]Array.<String>Tryte-encoded tags, one for each security level.
remainderObjectDestination for sending the remainder value (of the inputs) to.
remainder.addressStringTryte-encoded address, with or without the 9 tryte checksum
remainder.keyIndexIntegerIndex of the address
remainder.tagStringTryte-encoded tag. Maximum value is 27 trytes.
nowfunctionDate.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

0.6.5

3 years ago

0.6.3

3 years ago

0.6.4

3 years ago

0.6.2

4 years ago

0.6.2-beta.0

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.1

6 years ago

0.4.0

6 years ago