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

iota-lib

v0.0.5

Published

fiware iota connector

Downloads

2

Readme

IOTA Lib

Build Status dependencies Status devDependencies Status Support badge Github issues Coverage Status License: MIT

This project is a library (wrapper around IOTA) ot integrate with FIWARE.

Background

FIWARE is an open source initiative defining a universal set of standards for context data management which facilitate the development of Smart Solutions for different domains such as Smart Cities, Smart Industry, Smart Agrifood, and Smart Energy. IOTA is an open-source distributed ledger that is being built to power the future of the Internet of Things with feeless microtransactions and data integrity for machines. This library is an intial library(wrapper around IOTA libs) to support FIWARE Ecosystem.

Installation

npm install --save iota-lib

Functions

getProvider() ⇒ string

get the url of the provider Returns: string - endpoint of the provider

getTcpProvider() ⇒ string

get the url of Tcp provider (zmq endpoint) Returns: string- endpoint of the provider

setProvider()

set a new provider instead default

https://nodes.devnet.thetangle.org:443

setTcpProvider()

set TcpProvider instead default (zmq endpoint)

tcp://zmq.devnet.iota.org:5556

getNodeInfo() ⇒ Promise

get the information about the node Returns: Promise - callback with Object, Object if any

createMamTransaction(data, [options]) ⇒ Promise

Create MaM transaction Returns: Promise - callback with Object, Object if any

| Param | Type | Default | Description | | --------- | ------ | ----------------- | --------------------------------------------------------------------- | | data | string | | data to be submitted in iota | | [options] | object | { mode : public } | (optional) for restricted options = {mode: restricted, secret: value} |

fetchMamTransaction(hash, mode, secret) ⇒ Promise

Fetch MaM transaction Returns: Promise - callback with Object, Object if any

| Param | Type | Description | | ------ | ------ | -------------------------------------------------- | | hash | string | hash to be fetched | | mode | string | mode could be either public or restricted | | secret | string | secret of the data in case of restricted mode only |

createTransaction(address, seed, message, tag) ⇒ Promise

Create a transaction

Returns: Promise - callback with Object, Object if any

| Param | Type | Description | | ------- | ------ | ------------------------------------------------ | | address | string | address of the user | | seed | string | seed belong to the address to create transaction | | message | string | value to be put in transation | | tag | string | (optional) tag |

fetchTransaction(address) ⇒ Promise

fetch transactions belongs to specific address

Returns: Promise - callback with Object, Object if any

| Param | Type | Description | | ------- | ------ | ------------------- | | address | string | address of the user |

statusTransaction(transactions) ⇒ Promise

status of the transactions

Returns: Promise - callback with Object, Object if any

| Param | Type | Description | | ------------ | ----- | ---------------- | | transactions | Array | transaction Hash |

confirmTransaction(transactions) ⇒ Promise

confirm of the transaction mannually (if any conflict)

Returns: Promise - callback with Object, Object if any

| Param | Type | Description | | ------------ | ----- | ---------------- | | transactions | Array | transaction Hash |

generateSeed() ⇒ string

Create a new seed

Returns: string - generated seed

createNewAddress(seed, [options]) ⇒ Promise

Create a new address

Returns: Promise - callback with Object, Object if any

| Param | Type | Default | Description | | --------- | ------ | ----------------------- | ----------------------------------------------------------------------------------- | | seed | string | | seed to be use to create a new account | | [options] | Object | {index: 0, security: 2} | (optional) options, same address will be derived if seed, index and secuity is same |

getBalance(address) ⇒ Promise

get balance of the account

Returns: Promise - callback with Object, Object if any

| Param | Type | Description | | ------- | ------ | ----------- | | address | string | address |

sortTransactionMessage(transaction) ⇒ Array

sort transaction messages

Returns: Array - sorted transactions

| Param | Type | Description | | ----------- | ----- | ------------ | | transaction | Array | transactions |

decodeMessage(encodedMessage) ⇒ string

decode encoded message

Returns: string - decoded message

| Param | Type | Description | | -------------- | ------ | --------------- | | encodedMessage | string | encoded Message |

encodeMessage(decodedMessage) ⇒ string

encode decoded message

Returns: string - encoded message

| Param | Type | Description | | -------------- | ------ | --------------- | | decodedMessage | string | decoded Message |

Usages

set of possible operations:

Get the information of the node

import { getNodeInfo } from "iota-lib";

getNodeInfo()
    .then(res => {
        console.log(`res is${JSON.stringify(res)}`);
    })
    .catch(err => {
        console.log(`err${JSON.stringify(err)}`);
    });

Create a new account

create of an account followed up with 2 steps: 1. create a new seed (you can also skip this step by using your existing seed) 2. calling a create new account function

import { generateSeed, createNewAddress } from "iota-lib";
//generate a new seed
const seed = generateSeed();
//create a new account
createNewAddress(seed)
    .then(res => {
        console.log(`address is:${res}`);
    })
    .catch(err => {
        console.log(`err is:${err}`);
    });

Create a new Transaction

create of an account followed up with 2 steps: 1. create a new seed (you can also skip this step by using your existing seed) 2. calling a create new account function

import { generateSeed, createNewAddress } from "iota-lib";
//generate a new seed
const seed = generateSeed();
//create a new account
createNewAddress(seed)
    .then(res => {
        console.log(`address is:${res}`);
    })
    .catch(err => {
        console.log(`err is:${err}`);
    });

Fetch any Transaction

import { fetchTransaction } from "iota-lib";
fetchTransaction("HEQLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWOR99D")
    .then(res => {
        console.log(`response is :${JSON.stringify(res)}`);
    })
    .catch(err => {
        console.log(`err is :${JSON.stringify(err)}`);
    });

Status of any Transaction

import { statusTransaction } from "iota-lib";

statusTransaction(["VDEVCBMSEUTOJNWSBCRQHJWAWXZCTFYUGFZXEPCFUVXQHEPQNL9I9BMMVFTUFTDEPRHRGPAIRAOVKQ999"])
    .then(res => {
        console.log(`response is :${JSON.stringify(res)}`);
    })
    .catch(err => {
        console.log(`err is :${JSON.stringify(err)}`);
    });

Create a MaM Transaction (public)

import { createMamTransaction } from "iota-lib";

createMamTransaction("test")
    .then(re => {
        console.log(`re is${JSON.stringify(re)}`);
    })
    .catch(er => {
        console.log(`er is${JSON.stringify(er)}`);
    });

Create a MaM Transaction (private)

import { createMamTransaction } from "iota-lib";

createMamTransaction("test", { mode: "restricted", secret: "1234" })
    .then(re => {
        console.log(`re is${JSON.stringify(re)}`);
    })
    .catch(er => {
        console.log(`er is${JSON.stringify(er)}`);
    });

Fetch a MaM Transaction (public)

import { fetchMamTransaction, decodeMessage } from "iota-lib";

fetchMamTransaction(
    "9QBGGEEYGPNRZ9NQYBIVBNRJVPXWJUFHTKSRHOJZTNNKOBPBWGSXD9QRABWFDNP9VDOCRVHEIDPOWIUWC",
    "public",
    null,
    res => {
        const msg = decodeMessage(res);
        console.log(`message${msg}`);
    }
);

Fetch a MaM Transaction (private)

import { fetchMamTransaction, decodeMessage } from "iota-lib";

fetchMamTransaction(
    "QQUTOYQDKWGEOSNDERIUTLNFJLKXKPGMZVDJJJNPMSXSIYHJDUUMZUEI9GGQSFQJD9GRVGCMNDDATPWDN",
    "restricted",
    "DONTSHARETHIS",
    res => {
        const msg = decodeMessage(res);
        console.log(`message${msg}`);
    }
);

Pending (implementation)

  1. getBalance
  2. confirmTransaction
  3. Test-Case

License

MIT © 2020 FIWARE Foundation e.V.