Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Message

Encode a Hyperlane mailbox message. Outputs the binary layout the Hyperlane router expects.

Signature

class Message implements Encoder {
  version: number
  nonce: number
  originDomain: Domain
  sender: Addr32
  destinationDomain: Domain
  recipient: Addr32
  body: Uint8Array
 
  static from(params: Omit<Message, "encode" | "decode">): Message
  encode(): Uint8Array
}
 
const MAILBOX_VERSION: number          // 3
const HYPERLANE_DOMAIN_KEY: string     // "HYPERLANE"

Example

import { Addr32, Message, MAILBOX_VERSION } from "@left-curve/sdk/hyperlane"
 
const msg = Message.from({
  version: MAILBOX_VERSION,
  nonce: 0,
  originDomain: 1,
  sender: Addr32.from("0x1234567890abcdef1234567890abcdef12345678"),
  destinationDomain: 2,
  recipient: Addr32.from("0xabcdef1234567890abcdef1234567890abcdef12"),
  body: new Uint8Array([1, 2, 3]),
})
 
const wire: Uint8Array = msg.encode() // 77 + body bytes

Encoding layout

encode() produces a buffer of 77 + body.byteLength bytes:

OffsetLengthField
01version
14nonce (BE)
54originDomain (BE)
932sender
414destinationDomain (BE)
4532recipient
77Nbody

See also