Skip to main content
Version: 5.24.3

Namespace: num

References​

BigNumberish​

Re-exports BigNumberish

Functions​

isHex​

â–¸ isHex(hex): boolean

Test if string is hex-string

Parameters​

NameTypeDescription
hexstringhex-string

Returns​

boolean

Defined in​

src/utils/num.ts:14


toBigInt​

â–¸ toBigInt(value): bigint

Convert BigNumberish to bigint

Parameters​

NameType
valueBigNumberish

Returns​

bigint

Defined in​

src/utils/num.ts:21


isBigInt​

â–¸ isBigInt(value): value is bigint

Test if value is bigint

Parameters​

NameType
valueany

Returns​

value is bigint

Defined in​

src/utils/num.ts:28


toHex​

â–¸ toHex(number): string

Convert BigNumberish to hex-string

Parameters​

NameType
numberBigNumberish

Returns​

string

format: hex-string

Defined in​

src/utils/num.ts:36


toStorageKey​

â–¸ toStorageKey(number): string

Convert BigNumberish to storage-key-string

Same as toHex but conforming to the STORAGE_KEY pattern ^0x0[0-7]{1}[a-fA-F0-9]{0,62}$.

A storage key is represented as up to 62 hex digits, 3 bits, and 5 leading zeroes: 0x0 + [0-7] + 62 hex = 0x + 64 hex

Parameters​

NameType
numberBigNumberish

Returns​

string

format: storage-key-string

Defined in​

src/utils/num.ts:54


hexToDecimalString​

â–¸ hexToDecimalString(hex): string

Convert hexadecimal string to decimal string

Parameters​

NameTypeDescription
hexstringhex-string

Returns​

string

format: decimal string

Defined in​

src/utils/num.ts:64


assertInRange​

â–¸ assertInRange(input, lowerBound, upperBound, inputName?): void

Asserts input is equal to or greater then lowerBound and lower then upperBound.

The inputName parameter is used in the assertion message.

Parameters​

NameTypeDefault value
inputBigNumberishundefined
lowerBoundBigNumberishundefined
upperBoundBigNumberishundefined
inputNamestring''

Returns​

void

Defined in​

src/utils/num.ts:81


bigNumberishArrayToDecimalStringArray​

â–¸ bigNumberishArrayToDecimalStringArray(rawCalldata): string[]

Convert BigNumberish array to decimal string array

Parameters​

NameType
rawCalldataBigNumberish[]

Returns​

string[]

format: decimal string array

Defined in​

src/utils/num.ts:102


bigNumberishArrayToHexadecimalStringArray​

â–¸ bigNumberishArrayToHexadecimalStringArray(rawCalldata): string[]

Convert BigNumberish array to hexadecimal string array

Parameters​

NameType
rawCalldataBigNumberish[]

Returns​

string[]

format: hex-string array

Defined in​

src/utils/num.ts:110


getDecimalString​

â–¸ getDecimalString(value): string

Convert string to decimal string

Parameters​

NameType
valuestring

Returns​

string

format: decimal string

Defined in​

src/utils/num.ts:123


getHexString​

â–¸ getHexString(value): string

Convert string to hexadecimal string

Parameters​

NameType
valuestring

Returns​

string

format: hex-string

Defined in​

src/utils/num.ts:137


getHexStringArray​

â–¸ getHexStringArray(value): string[]

Convert string array to hex-string array

Parameters​

NameType
valuestring[]

Returns​

string[]

format: hex-string array

Defined in​

src/utils/num.ts:151


hexToBytes​

â–¸ hexToBytes(value): Uint8Array

Convert hex-string to an array of Bytes (Uint8Array)

Parameters​

NameTypeDescription
valuestringhex-string

Returns​

Uint8Array

Defined in​

src/utils/num.ts:164


toHexString​

â–¸ toHexString(number): string

Alias of ToHex

Parameters​

NameType
numberBigNumberish

Returns​

string

Defined in​

src/utils/num.ts:36


cleanHex​

â–¸ cleanHex(hex): string

Remove hex string leading zero and lowercase it

Example

'0x01A...' -> '0x1a..'

Parameters​

NameTypeDescription
hexstringhex-string

Returns​

string

format: hex-string

Defined in​

src/utils/num.ts:74


isStringWholeNumber​

â–¸ isStringWholeNumber(value): boolean

Test if string is whole number (0, 1, 2, 3...)

Parameters​

NameType
valuestring

Returns​

boolean

Defined in​

src/utils/num.ts:117


toCairoBool​

â–¸ toCairoBool(value): string

Convert boolean to "0" or "1"

Parameters​

NameType
valueboolean

Returns​

string

Defined in​

src/utils/num.ts:158