Skip to main content

Class: HexHelper

Helper methods for hex conversions.

Table of contents

Properties

Methods

Constructors

Properties

BIG_INT_MAX_256_BIT

Static Readonly BIG_INT_MAX_256_BIT: BigInteger

Const defining the maximum value for a 256 bit int.

Methods

fromBigInt256

Static fromBigInt256(value): string

Convert the big int 256 bit to hex string.

Parameters

NameTypeDescription
valueBigIntegerThe big int value to convert.

Returns

string

The hex encoded big int.


toBigInt256

Static toBigInt256(hex): BigInteger

Convert the hex string to a big int.

Parameters

NameTypeDescription
hexstringThe hex value to convert.

Returns

BigInteger

The big int.


stripPrefix

Static stripPrefix(hex): string

Strip the 0x prefix if it exists.

Parameters

NameTypeDescription
hexstringThe hex value to strip.

Returns

string

The stripped hex without the prefix.


addPrefix

Static addPrefix(hex): string

Add the 0x prefix if it does not exist.

Parameters

NameTypeDescription
hexstringThe hex value to add the prefix to.

Returns

string

The hex with the prefix.


hasPrefix

Static hasPrefix(hex): boolean

Does the hex string have the prefix.

Parameters

NameTypeDescription
hexstringThe hex value to check for the prefix.

Returns

boolean

True if the hex string has the prefix.

Constructors

constructor

new HexHelper()