Convert Satoshi <-> Bitcoin
npm install satoshi-bitcoin


> npm module to convert between Satoshi and Bitcoin with lightweight precision.
``bash
npm install --save satoshi-bitcoin
yarn add satoshi-bitcoin
`
#### Node.js
`js
var sb = require("satoshi-bitcoin");
sb.toSatoshi(1);
//=>100000000
sb.toBitcoin(100000000);
//=>1
`
#### Web
`html`
Or download it with npm install --save satoshi-bitcoin and reference it as:
`html`
`javascript`
try {
sb.toSatoshi(false); //Throws TypeError
} catch (err) {
console.log(err);
}
sb.toSatoshi(number || string)sb.toBitcoin(number || string)
- What is a Satoshi?
- Satoshi is to Bitcoin as pennies are to the dollar. Except that there are 100,000,000 Satoshi in one Bitcoin.
- Why do I need a module when I can just divide or multiply by 100,000,000?
- See here - Floating point errors are a problem. So satoshi-bitcoin uses a tiny bignum library (big.js) to ensure accurate conversions!
`bash``
npm test
MIT © Dawson Botsford