Skip to content

floTokenAPI

Sai Raj edited this page May 26, 2023 · 2 revisions

FLO Token API Operations

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');

Default values

This module uses some default values. They can be overwritten by assigning values floGlobals.

DEFAULT = {
    apiURL: "https://ranchimallflo.duckdns.org/",
    currency: "rupee"
}

apiURL

Default FLO Token API URL.

Can be overwritten using floGlobals.tokenURL

currency

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 API fetch function

Base fetch function that other functions use to request data from floSight API.

floTokenAPI.fetch(apicall)
  1. apicall - API uri
  • Resolves: responseData from the API

Address and transaction queries

Balance check

floTokenAPI.getBalance(floID, token)

Requests token balance for specified FLO address.

  1. floID - FLO address
  2. token (optional) - Token name (uses DEFAULT.currency if not specified)
  • Resolves: balance (Number)

Get details of a transaction

floTokenAPI.getTx(txid)

Requests the transaction details of a given txid

  1. txid - transaction ID
  • Resolves: transaction_details (Object)

Get all transactions

floTokenAPI.getAllTxs(floID, token)

Requests all transactions for a given floID and token

  1. floID - FLO address
  2. token (optional) - Token name (uses DEFAULT.currency if not specified)
  • Resolves: list of transaction_details

Sending tokens

Single transfer (one to one)

floTokenAPI.sendToken(privKey, amount, receiverID, message, token, options)

Transfers token from sender to receiver

  1. privKey - private-key of sender
  2. amount - amount of token to be sent
  3. receiverID - receiver floID
  4. message (optional) - additional message to be written in floData. (DEFAULT: '')
  5. token (optional) - Token name (uses DEFAULT.currency if not specified)
  6. 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)

Bulk transfer (one to many)

floTokenAPI.bulkTransferTokens(sender, privKey, token, receivers)

Transfers tokens from one sender to multiple receivers (in seperate transactions)

  1. sender - floID of sender
  2. privKey - private-key of sender
  3. token - name of the token to be transfered
  4. receivers - (Object) receiver floID and amount pairs. i.e, in format {receiver1: amount1, receiver2:amount2...}
  • Resolves: (Object) List of transaction IDs