translib
v1.0.31
Published
A small library of functions routinely used in the transledger architecture. They are all bunched here for easy access, easy modification and to give a uniform convention for the different recurrent quantities.
Downloads
11
Readme
translib
A small library of functions routinely used in the transledger architecture. They are all bunched here for easy access, easy modification and to give a uniform convention for the different recurrent quantities.
#Installation In the liteAuditor directory, simply issue:
npm install --save translib
Usage
Simply import the module.
const TransLib = require("translib")
const translib = new TransLib();
Then you can invoke the methods:
let value = translib.convertAmountToInteger(amount, ticker);
Methods
convertAmountToInteger(amount, ticker)
This method is used for converting amounts to a representation in terms of their smallest unit (BTC => Satoshi, ETH => Wei, etc).
Parameters:
amount: string or number ticker: token symbol, one of (TBTC, TLTC, TBCH, TETH, TEOS, TXLM, TXRP, BTC, LTC, BCH, ETH, EOS, XLM, XRP)
convertAmountToDecimal(amount, ticker)
This method is used for converting amounts from integer to decimal representations (ex: 200000 Satoshi => 0.002 BTC).
Parameters:
amount: string or number ticker: token symbol, one of (TBTC, TLTC, TBCH, TETH, TEOS, TXLM, TXRP, BTC, LTC, BCH, ETH, EOS, XLM, XRP)
uuidv4()
Generate a random uuid with pattern 8-4-4-4-12.
getNetworkSymbol(Network)
Returns a symbol representing the network. For now, they all point towards the testnets.
Parameter:
Network: one of (TBTC, TLTC, TBCH, TETH, TEOS, TXLM, TXRP, BTC, LTC, BCH, ETH, EOS, XLM, XRP)
getBlockchainType(Network)
Returns the type of blockchains (UTXO or Account)
Parameter:
Network: one of (TBTC, TLTC, TBCH, TETH, TEOS, TXLM, TXRP, BTC, LTC, BCH, ETH, EOS, XLM, XRP)
logTime()
Returns the Date and Time in a chosen format
Prerequisite
- node: install node from here
Prior to run, install all dependencies with npm install
. To view dependencies, please refer to the package.json file.