IOTA Lib
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
; ;
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
;//generate a new seedconst seed = ;//create a new account ;
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
;//generate a new seedconst seed = ;//create a new account ;
Fetch any Transaction
; ;
Status of any Transaction
; ;
Create a MaM Transaction (public)
; ;
Create a MaM Transaction (private)
; ;
Fetch a MaM Transaction (public)
; ;
Fetch a MaM Transaction (private)
; ;
Pending (implementation)
- getBalance
- confirmTransaction
- Test-Case
License
MIT © 2020 FIWARE Foundation e.V.