floTokenAPI
floTokenAPI
module provides functions to fetch data and send tokens from the FLO token system. These functions are asynchronous and return a promise.
NOTE: All of FLO Token API operations have been promisified. i.e, output needs to be handled using .then and .catch
Example:
floTokenAPI.someFunction(parameters)
.then(result => process_resolve(result))
.catch(error => process_reject(error))
Note: for nodejs use require and assign floTokenAPIto global
global.floTokenAPI = require('/path/to/floTokenAPI');
This module uses some default values. They can be overwritten by assigning values floGlobals.
DEFAULT = {
apiURL: "https://ranchimallflo.duckdns.org/",
currency: "rupee"
}
Default FLO Token API URL.
Can be overwritten using floGlobals.tokenURL
Default token to use when token is not specified.
Default value: rupee
Can be overwritten using floGlobals.currency
floTokenAPI.currency
setter and getter can be used to update or get the default currency value. Example:
floTokenAPI.currency = 'USD';
var currency = floTokenAPI.currency;
Base fetch function that other functions use to request data from floSight API.
floTokenAPI.fetch(apicall)
- apicall - API uri
- Resolves: responseData from the API
floTokenAPI.getBalance(floID, token)
Requests token balance for specified FLO address.
- floID - FLO address
- token (optional) - Token name (uses DEFAULT.currency if not specified)
- Resolves: balance (Number)
floTokenAPI.getTx(txid)
Requests the transaction details of a given txid
- txid - transaction ID
- Resolves: transaction_details (Object)
floTokenAPI.getAllTxs(floID, token)
Requests all transactions for a given floID and token
- floID - FLO address
- token (optional) - Token name (uses DEFAULT.currency if not specified)
- Resolves: list of transaction_details
floTokenAPI.sendToken(privKey, amount, receiverID, message, token, options)
Transfers token from sender to receiver
- privKey - private-key of sender
- amount - amount of token to be sent
- receiverID - receiver floID
- message (optional) - additional message to be written in floData. (DEFAULT: '')
- token (optional) - Token name (uses DEFAULT.currency if not specified)
- options (optional) - options of
floBlockchainAPI.writeData
-
strict_utxo
: (boolean) include unconfirmed utxos or not -
sendAmt
: (decimal) FLO amount to send (uses floBlockchainAPI's DEFAULT.sendAmt if not specified)
-
- Resolves: TransactionID (String)
floTokenAPI.bulkTransferTokens(sender, privKey, token, receivers)
Transfers tokens from one sender to multiple receivers (in seperate transactions)
- sender - floID of sender
- privKey - private-key of sender
- token - name of the token to be transfered
- receivers - (Object) receiver floID and amount pairs. i.e, in format
{receiver1: amount1, receiver2:amount2...}
- Resolves: (Object) List of transaction IDs