1.0.7 • Published 6 years ago

@decentralized-auth/iota v1.0.7

Weekly downloads
2
License
Apache-2.0
Repository
-
Last release
6 years ago

@decentralized-auth/iota

GitHub license

Wrapper class for the IOTA client that provides some convenience methods for use in the decentralized-auth project.

Usage

const IotaClient = require('@decentralized-auth/iota');

const iota = new IotaClient({
  provider: 'http://node01.testnet.iotatoken.nl:16265',
  securityLevel: 2,
  depth: 5,
  minWeightMagnitude: 10,
});

With logger:

// Instantiate a logger that has an info and error method
const consoleLogger = new (function () {
  this.info = console.log;
  this.error = console.log;
})();

const iota = new IotaClient({
  provider: 'http://node01.testnet.iotatoken.nl:16265',
  securityLevel: 2,
  depth: 5,
  minWeightMagnitude: 10,
}, consoleLogger);

Test

npm run test

Lint

npm run lint

Documentation

Documentation generated from docstrings with jsdoc2md.

iota

Wrapper for the IOTA client that provides some convenience methods.


iota~IotaClient

Kind: inner class of iota


new IotaClient(iotaOptions, logger)

Constructor for an IotaClient.

ParamTypeDescription
iotaOptionsobjectwith: - {string} provider IOTA provider (host URL) - {number} minWeightMagnitude Minimum weight magnitude for PoW - {number} securityLevel IOTA security level - {number} depth IOTA depth
loggerobjectShould support the methods info and error

iota~send(seed, receiver, message)Promise

Send a message via IOTA.

Kind: inner method of iota

ParamTypeDescription
seedstringOur IOTA seed
receiverstringIOTA address of receiver
messageJSONto send

iota~getLastMessage(searchValues)JSON

Gets last received transfer message. NOTE: order is not necessarily chronological, but let's assume it is.

Kind: inner method of iota
Returns: JSON - Parsed message or null when no received transfers

ParamTypeDescription
searchValuesObjectList of bundle hashes, addresses, tags or approvees (e.g., { hashes: ['ABCD'] })

iota~getAddress(seed, amount)Promise

Gets the first addresses with security level for seed starting at index 0.

Kind: inner method of iota
Returns: Promise - With result or reject with error

ParamTypeDescription
seedstringIOTA seed to generate an address for
amountstringAmount of addresses to return

iota~toTrytes(text)string

Converts text to trytes.

Kind: inner method of iota
Returns: string - Trytes

ParamTypeDescription
textstringText to convert

iota~fromTrytes(trytes)string

Converts trytes to string. Also works with odd length trytes string.

Kind: inner method of iota
Returns: string - Converted string

ParamTypeDescription
trytesstringTrytes to convert

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago