Files
common/docs/util/modules/_hex_tou8a_.md
T
2019-02-15 09:32:54 +00:00

971 B

Functions

hexToU8a

▸ hexToU8a(_value?: string | null, bitLength?: number): Uint8Array

Defined in hex/toU8a.ts:24

name: hexToU8a

summary: Creates a Buffer object from a hex string.

description: null inputs returns an empty Uint8Array result. Hex input values return the actual bytes value converted to a Uint8Array. Anything that is not a hex string (including the 0x prefix) throws an error.

example:

import { hexToU8a } from '@polkadot/util';

hexToU8a('0x80001f'); // Uint8Array([0x80, 0x00, 0x1f])
hexToU8a('0x80001f', 32); // Uint8Array([0x00, 0x80, 0x00, 0x1f])

Parameters:

Name Type Default value
Optional _value string null
Default value bitLength number -1

Returns: Uint8Array