web3x
Version:
Typescript port of web3.js
78 lines (77 loc) • 2.46 kB
TypeScript
import BN from 'bn.js';
export declare const unitMap: {
noether: string;
wei: string;
kwei: string;
Kwei: string;
babbage: string;
femtoether: string;
mwei: string;
Mwei: string;
lovelace: string;
picoether: string;
gwei: string;
Gwei: string;
shannon: string;
nanoether: string;
nano: string;
szabo: string;
microether: string;
micro: string;
finney: string;
milliether: string;
milli: string;
ether: string;
kether: string;
grand: string;
mether: string;
gether: string;
tether: string;
};
/**
* Takes a number of wei and converts it to any other ether unit.
*
* Possible units are:
* SI Short SI Full Effigy Other
* - kwei femtoether babbage
* - mwei picoether lovelace
* - gwei nanoether shannon nano
* - -- microether szabo micro
* - -- milliether finney milli
* - ether -- --
* - kether -- grand
* - mether
* - gether
* - tether
*
* @method fromWei
* @param {Number|String} num can be a number, number string or a HEX of a decimal
* @param {String} unit the unit to convert to, default ether
* @return {String|Object} When given a BN object it returns one as well, otherwise a number
*/
export declare function fromWei(num: string, unit: keyof typeof unitMap): string;
export declare function fromWei(num: BN, unit: keyof typeof unitMap): BN;
/**
* Takes a number of a unit and converts it to wei.
*
* Possible units are:
* SI Short SI Full Effigy Other
* - kwei femtoether babbage
* - mwei picoether lovelace
* - gwei nanoether shannon nano
* - -- microether szabo micro
* - -- microether szabo micro
* - -- milliether finney milli
* - ether -- --
* - kether -- grand
* - mether
* - gether
* - tether
*
* @method toWei
* @param {Number|String|BN} num can be a number, number string or a HEX of a decimal
* @param {String} unit the unit to convert from, default ether
* @return {String|Object} When given a BN object it returns one as well, otherwise a number
*/
export declare function toWei(num: BN, unit: keyof typeof unitMap): BN;
export declare function toWei(num: string, unit: keyof typeof unitMap): string;