Function: decodeMessage()
decodeMessage(
data:string|Record<string,unknown> |Uint8Array<ArrayBufferLike>):CCIPMessage
Defined in: requests.ts:150
Decodes hex strings, bytearrays, JSON strings and raw objects as CCIPMessages. Does minimal validation, but converts objects in the format expected by ccip-tools-ts.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | string | Record<string, unknown> | Uint8Array<ArrayBufferLike> | Data to decode (hex string, Uint8Array, JSON string, or object) |
Returns
Decoded CCIPMessage
Throws
CCIPMessageDecodeError if data cannot be decoded as a valid message
Throws
CCIPMessageInvalidError if message structure is invalid or missing required fields
Example
TypeScript
import { decodeMessage } from '@chainlink/ccip-sdk'
// Decode from JSON string
const message = decodeMessage('{"header":{"sourceChainSelector":"123",...}')
// Decode from hex-encoded bytes
const message = decodeMessage('0x...')
console.log('Message ID:', message.messageId)