Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@ethersproject/units
Advanced tools
@ethersproject/units is a utility library for handling and converting between different units of Ether and other cryptocurrencies. It provides functions to parse and format units, making it easier to work with values in different denominations.
parseUnits
The `parseUnits` function converts a string representation of a value in a specified unit to its equivalent in wei (the smallest unit of Ether). In this example, '1.0' Ether is converted to '1000000000000000000' wei.
const { parseUnits } = require('@ethersproject/units');
const weiValue = parseUnits('1.0', 'ether');
console.log(weiValue.toString()); // '1000000000000000000'
formatUnits
The `formatUnits` function converts a value in wei to a string representation in a specified unit. In this example, '1000000000000000000' wei is converted to '1.0' Ether.
const { formatUnits } = require('@ethersproject/units');
const etherValue = formatUnits('1000000000000000000', 'ether');
console.log(etherValue); // '1.0'
commify
The `commify` function adds commas to a numeric string for better readability. In this example, '1234567.890123' is formatted to '1,234,567.890123'.
const { commify } = require('@ethersproject/units');
const formattedValue = commify('1234567.890123');
console.log(formattedValue); // '1,234,567.890123'
The `web3-utils` package is part of the Web3.js library and provides utility functions for Ethereum dapp development. It includes functions for unit conversion, such as `toWei` and `fromWei`, which are similar to `parseUnits` and `formatUnits` in @ethersproject/units. However, `web3-utils` is more tightly integrated with the Web3.js ecosystem.
The `bignumber.js` package is a library for arbitrary-precision decimal and non-decimal arithmetic. While it does not specifically focus on Ethereum unit conversions, it can be used in conjunction with other libraries to handle large numbers and perform precise calculations, similar to the functionality provided by @ethersproject/units.
The `ethers` package is a complete Ethereum library that includes the `@ethersproject/units` module as part of its functionality. It provides a comprehensive set of tools for interacting with the Ethereum blockchain, including unit conversion, contract interaction, and wallet management. It is more feature-rich compared to @ethersproject/units alone.
EXPERIMENTAL
Please see the ethers repository for more informations.
@TODO
MIT License
FAQs
Unit conversion functions for Ethereum.
The npm package @ethersproject/units receives a total of 266,431 weekly downloads. As such, @ethersproject/units popularity was classified as popular.
We found that @ethersproject/units demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.