🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@tokensoft/conversions

Package Overview
Dependencies
Maintainers
7
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tokensoft/conversions

Utils to convert values between on-chain "base" and human-readable "display" units

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
0
Maintainers
7
Weekly downloads
 
Created
Source

Conversions

Utils to convert values between on-chain "base" and human-readable "display" units

Installation

$ yarn add @tokensoft/conversions
$ npm install @tokensoft/conversions

Usage

import { toBaseUnit, toDisplayUnit } from '@tokensoft/conversions'

const ethValue = '1'
const weiValue = '1000000000000000000'
const decimals = 18

const baseValue = toBaseUnit(ethValue, decimals) // => '1000000000000000000'
const displayValue = toDisplayUnit(weiValue, decimals) // => '1'

Functions

toBaseUnit(value, decimals) ⇒ String

Converts value denominated in human-readable "display" unit (ether, bitcoins) to value denominated in on-chain "base" unit (wei, satoshis)

toDisplayUnit(value, decimals) ⇒ String

Converts value denominated in on-chain "base" unit (wei, satoshis) to value denominated in human-readable "display" unit (ether, bitcoins)

toBaseUnit(value, decimals) ⇒ String

Converts value denominated in human-readable "display" unit (ether, bitcoins) to value denominated in on-chain "base" unit (wei, satoshis)

Kind: global function

ParamType
valueString | Number | BigNumber
decimalsString | Number | BigNumber

toDisplayUnit(value, decimals) ⇒ String

Converts value denominated in on-chain "base" unit (wei, satoshis) to value denominated in human-readable "display" unit (ether, bitcoins)

Kind: global function

ParamType
valueString | Number | BigNumber
decimalsString | Number | BigNumber

FAQs

Package last updated on 18 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts