fiware iota connector
npm install iota-lib






This project is a library (wrapper around IOTA) ot integrate with FIWARE.
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.
``sh`
npm install --save iota-lib
get the url of the provider Returns: string - endpoint of the provider
get the url of Tcp provider (zmq endpoint) Returns: string- endpoint of the provider
set a new provider instead default
``
https://nodes.devnet.thetangle.org:443
set TcpProvider instead default (zmq endpoint)
``
tcp://zmq.devnet.iota.org:5556
get the information about the node Returns: Promise - callback with
Create MaM transaction Returns: Promise - callback with
| Param | Type | Default | Description |
| --------- | ------ | ----------------- | --------------------------------------------------------------------- |
| data | string | | data to be submitted in iota |
| [options] | object | { mode : public } | (optional) for restricted options = {mode: restricted, secret: value} |
Fetch MaM transaction Returns: Promise - callback with
| 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 |
Create a transaction
Returns: Promise - callback with
| 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 |
fetch transactions belongs to specific address
Returns: Promise - callback with
| Param | Type | Description |
| ------- | ------ | ------------------- |
| address | string | address of the user |
status of the transactions
Returns: Promise - callback with
| Param | Type | Description |
| ------------ | ----- | ---------------- |
| transactions | Array | transaction Hash |
confirm of the transaction mannually (if any conflict)
Returns: Promise - callback with
| Param | Type | Description |
| ------------ | ----- | ---------------- |
| transactions | Array | transaction Hash |
Create a new seed
Returns: string - generated seed
Create a new address
Returns: Promise - callback with
| 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 |
get balance of the account
Returns: Promise - callback with
| Param | Type | Description |
| ------- | ------ | ----------- |
| address | string | address |
sort transaction messages
Returns: Array - sorted transactions
| Param | Type | Description |
| ----------- | ----- | ------------ |
| transaction | Array | transactions |
decode encoded message
Returns: string - decoded message
| Param | Type | Description |
| -------------- | ------ | --------------- |
| encodedMessage | string | encoded Message |
encode decoded message
Returns: string - encoded message
| Param | Type | Description |
| -------------- | ------ | --------------- |
| decodedMessage | string | decoded Message |
set of possible operations:
`js
import { getNodeInfo } from "iota-lib";
getNodeInfo()
.then(res => {
console.log(res is${JSON.stringify(res)});err${JSON.stringify(err)}
})
.catch(err => {
console.log();`
});
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
`jsaddress is:${res}
import { generateSeed, createNewAddress } from "iota-lib";
//generate a new seed
const seed = generateSeed();
//create a new account
createNewAddress(seed)
.then(res => {
console.log();err is:${err}
})
.catch(err => {
console.log();`
});
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
`jsaddress is:${res}
import { generateSeed, createNewAddress } from "iota-lib";
//generate a new seed
const seed = generateSeed();
//create a new account
createNewAddress(seed)
.then(res => {
console.log();err is:${err}
})
.catch(err => {
console.log();`
});
`jsresponse is :${JSON.stringify(res)}
import { fetchTransaction } from "iota-lib";
fetchTransaction("HEQLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWOR99D")
.then(res => {
console.log();err is :${JSON.stringify(err)}
})
.catch(err => {
console.log();`
});
`js
import { statusTransaction } from "iota-lib";
statusTransaction(["VDEVCBMSEUTOJNWSBCRQHJWAWXZCTFYUGFZXEPCFUVXQHEPQNL9I9BMMVFTUFTDEPRHRGPAIRAOVKQ999"])
.then(res => {
console.log(response is :${JSON.stringify(res)});err is :${JSON.stringify(err)}
})
.catch(err => {
console.log();`
});
`js
import { createMamTransaction } from "iota-lib";
createMamTransaction("test")
.then(re => {
console.log(re is${JSON.stringify(re)});er is${JSON.stringify(er)}
})
.catch(er => {
console.log();`
});
`js
import { createMamTransaction } from "iota-lib";
createMamTransaction("test", { mode: "restricted", secret: "1234" })
.then(re => {
console.log(re is${JSON.stringify(re)});er is${JSON.stringify(er)}
})
.catch(er => {
console.log();`
});
`js
import { fetchMamTransaction, decodeMessage } from "iota-lib";
fetchMamTransaction(
"9QBGGEEYGPNRZ9NQYBIVBNRJVPXWJUFHTKSRHOJZTNNKOBPBWGSXD9QRABWFDNP9VDOCRVHEIDPOWIUWC",
"public",
null,
res => {
const msg = decodeMessage(res);
console.log(message${msg});`
}
);
`js
import { fetchMamTransaction, decodeMessage } from "iota-lib";
fetchMamTransaction(
"QQUTOYQDKWGEOSNDERIUTLNFJLKXKPGMZVDJJJNPMSXSIYHJDUUMZUEI9GGQSFQJD9GRVGCMNDDATPWDN",
"restricted",
"DONTSHARETHIS",
res => {
const msg = decodeMessage(res);
console.log(message${msg});``
}
);
1. getBalance
2. confirmTransaction
3. Test-Case
MIT © 2020 FIWARE Foundation e.V.