UNPKG

790 BTypeScriptView Raw
1/// <reference types="bn.js" />
2import type { HexString, NumberOptions, ToBn } from '../types.js';
3import type { BN } from './bn.js';
4/**
5 * @name bnToHex
6 * @summary Creates a hex value from a BN.js bignumber object.
7 * @description
8 * `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. With `bitLength` set, it fixes the number to the specified length.
9 * @example
10 * <BR>
11 *
12 * ```javascript
13 * import BN from 'bn.js';
14 * import { bnToHex } from '@polkadot/util';
15 *
16 * bnToHex(new BN(0x123456)); // => '0x123456'
17 * ```
18 */
19export declare function bnToHex<ExtToBn extends ToBn>(value?: ExtToBn | BN | bigint | number | null, { bitLength, isLe, isNegative }?: NumberOptions): HexString;