Converters

Table of Contents


BeatozUnitMap

A hashtable that stores the ratio between different units of BEATOZ.

export const beatozUnitMap = {
    nobeatoz: BigInt('0'),
    fons: BigInt(1),
    // ...
    tbeatoz: expo10(30),
};

BytesToUint8Array

This method converts an instance of Bytes into an instance of Uint8Array.

export const bytesToUint8Array = (data: Bytes): Uint8Array | never => {...}

BytesToHex

This method converts an instance of Bytes into a HexString.

export const bytesToHex = (bytes: Bytes): HexString => {...}

HexToBytes

This method converts an instance of HexString into Bytes.

export const hexToBytes = (bytes: HexString): Uint8Array => {...}

HexToNumber

This method converts an instance of HexString into a number.

export const hexToNumber = (value: HexString): bigint | number => {...}

ToDecimal

Alias for hexToNumber.

export const toDecimal = hexToNumber;

NumberToHex

This method converts a number into a HexString.

export const numberToHex = (value: Numbers, hexstrict?: boolean): HexString => {...}

FromDecimal

Alias for numberToHex.

export const fromDecimal = numberToHex;

Utf8ToHex

This method converts a string into a HexString.

export const utf8ToHex = (str: string): HexString => {...}

FromUtf8

Alias for utf8ToHex.

export const fromUtf8 = utf8ToHex;

StringToHex

Alias for utf8ToHex.

export const stringToHex = utf8ToHex;

HexToUtf8

This method converts a HexString into a string.

export const hexToUtf8 = (str: HexString): string => {...}

ToUtf8

This method converts an input (which can be HexString or Uint8Array) into a UTF-8 string.

export const toUtf8 = (input: HexString | Uint8Array) => {...}

HexToAscii

This method converts a HexString into an ASCII string.

export const hexToAscii = (str: HexString): string => {...}

ToAscii

Alias for hexToAscii.

export const toAscii = hexToAscii;

ToNumber

This method converts a Numbers value into a number or bigint representation.

export const toNumber = (value: Numbers): bigint|number => {...}

ToBigInt

This method converts any given value into its bigint representation.

export const toBigInt = (value: unknown): bigint => {...}

FromFons

This method converts a given number in fons into any other BEATOZ unit.

export const fromFons = (number: Numbers, unit: BeatozUnits): string => {...}

ToFons

This method converts a given number from a specified BEATOZ unit into fons.

export const toFons = (number: Numbers, unit: BeatozUnits): string => {...}

ToChecksumAddress

This method converts an address to a checksum address.

export const toChecksumAddress = (address: Address): string => {...}

Last updated