Bytes.fromHex
Encodes a Hex.Hex
value into Bytes.Bytes
.
Imports
Named
import { Bytes } from 'ox'
Examples
import { Bytes } from 'ox'
const data = Bytes.fromHex('0x48656c6c6f20776f726c6421')
Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
import { Bytes } from 'ox'
const data = Bytes.fromHex('0x48656c6c6f20776f726c6421', { size: 32 })
Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
Definition
function fromHex(
value: Hex.Hex,
options?: fromHex.Options,
): Bytes
Source: src/Bytes.ts
Parameters
value
- Type:
Hex.Hex
Hex.Hex
value to encode.
options
- Type:
fromHex.Options
- Optional
Encoding options.
options.size
- Type:
number
- Optional
Size of the output bytes.
Return Type
Encoded Bytes.Bytes
.
Bytes
Error Type
Bytes.fromHex.ErrorType