Files
common/docs/bn.md
T
Jaco Greeff d02c05ba49 Alias to <-> from (#31)
* bn <-> hex aliasses

* Bump minor

* Split tests into singular files

* to <-> from alias

* Add Codeclimate badge
2017-11-30 20:16:17 +01:00

772 B

bn

Utility methods to convert to and from BN objects

  • bnFromHex Creates a BN.js bignumber object from a hex string. [hex.md#hextobn](alias hexToBn)
  • bnToHex Creates a hex value from a BN.js bignumber object.

bnFromHex

Creates a BN.js bignumber object from a hex string. [hex.md#hextobn](alias hexToBn)

bnFromHex (value?: string): BN

bnToHex

Creates a hex value from a BN.js bignumber object.

bnToHex (value?: BN): string

null inputs returns a 0x result, BN values return the actual value as a 0x prefixed hex value. Anything that is not a BN object throws an error.

import BN from 'bn.js';
import { bnToHex } from '@polkadot/util';

console.log('Hex value', bnToHex(new BN(123456));