Skip to main content
Version: Next

Function: hexToBytes()

hexToBytes(str): Uint8Array

Defined in: src/utils/num.ts:328

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

Parameters

str

string

hex-string

Returns

Uint8Array

array containing the converted elements

Throws

str must be a hex-string

Example

let result;

result = hexToBytes('0x64');
// result = [100]

result = hexToBytes('test');
// throws Error: test needs to be a hex-string