@decentralized-auth/iota v1.0.7
@decentralized-auth/iota
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 testLint
npm run lintDocumentation
Documentation generated from docstrings with jsdoc2md.
iota
Wrapper for the IOTA client that provides some convenience methods.
- iota
- ~IotaClient
~send(seed, receiver, message)⇒ Promise~getLastMessage(searchValues)⇒ JSON~getAddress(seed, amount)⇒ Promise~toTrytes(text)⇒ string~fromTrytes(trytes)⇒ string
iota~IotaClient
Kind: inner class of iota
new IotaClient(iotaOptions, logger)
Constructor for an IotaClient.
| Param | Type | Description |
|---|---|---|
| iotaOptions | object | with: - {string} provider IOTA provider (host URL) - {number} minWeightMagnitude Minimum weight magnitude for PoW - {number} securityLevel IOTA security level - {number} depth IOTA depth |
| logger | object | Should support the methods info and error |
iota~send(seed, receiver, message) ⇒ Promise
Send a message via IOTA.
Kind: inner method of iota
| Param | Type | Description |
|---|---|---|
| seed | string | Our IOTA seed |
| receiver | string | IOTA address of receiver |
| message | JSON | to 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
| Param | Type | Description |
|---|---|---|
| searchValues | Object | List 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
| Param | Type | Description |
|---|---|---|
| seed | string | IOTA seed to generate an address for |
| amount | string | Amount of addresses to return |
iota~toTrytes(text) ⇒ string
Converts text to trytes.
Kind: inner method of iota
Returns: string - Trytes
| Param | Type | Description |
|---|---|---|
| text | string | Text 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
| Param | Type | Description |
|---|---|---|
| trytes | string | Trytes to convert |