Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc