
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
Convert fixed-point numbers to ethers big numbers and vice-versa. This is useful for EVM-related projects, since 1 ETH is 1e18 wei.
n + 1 and above, with n the number of decimals, rounding down in the process.With yarn:
$ yarn add evm-bn
Or npm:
$ npm install evm-bn
import type { BigNumber } from "@ethersproject/bignumber";
import { toBn } from "evm-bn";
// 3141500000000000000
const foo: BigNumber = toBn("3.1415");
// 115792089237316195423570985008687907853269984665640564039457584007913129639935
const bar: BigNumber = toBn("115792089237316195423570985008687907853269984665640564039457.584007913129639935");
// 100000000000000
const baz: BigNumber = toBn("100e6", 6);
import type { BigNumber } from "@ethersproject/bignumber";
import { fromBn } from "evm-bn";
// 3.1415
const foo: BigNumber = fromBn(BigNumber.from("3141500000000000000"));
// 115792089237316195423570985008687907853269984665640564039457.584007913129639935
const bar: BigNumber = fromBn(
BigNumber.from("115792089237316195423570985008687907853269984665640564039457584007913129639935"),
);
// 100000000
const baz: BigNumber = fromBn(BigNumber.from("100000000000000"), 6);
Feel free to dive in! Open an issue, start a discussion or submit a PR.
Clone the repositories and install the dependencies:
$ yarn install
Now you can start making changes.
MIT © Paul Razvan Berg
FAQs
Convert fixed-point numbers to ethers big numbers and vice-versa
The npm package evm-bn receives a total of 2,072 weekly downloads. As such, evm-bn popularity was classified as popular.
We found that evm-bn 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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.