Function: getDataBytes()
getDataBytes(
data:BytesLike| readonlynumber[]):Uint8Array
Defined in: utils.ts:387
Converts various data formats to Uint8Array.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | BytesLike | readonly number[] | Bytes, number array, or Base64 string. |
Returns
Uint8Array
Uint8Array representation.
Throws
CCIPDataFormatUnsupportedError if data format is not recognized
Example
TypeScript
import { getDataBytes } from '@chainlink/ccip-sdk'
// From hex string
const bytes1 = getDataBytes('0x1234abcd')
// From number array
const bytes2 = getDataBytes([0x12, 0x34, 0xab, 0xcd])
// From Base64
const bytes3 = getDataBytes('EjSrzQ==')