Messaging
Send a message from XE to another chain with dispatch, and receive one with message_receive, on EVM and Solana.
XE speaks Hyperlane v3. A message from XE is a dispatch block on the sender's own account chain. A message into XE is a message_receive block on the recipient's account chain. Everything else on these pages is built on those two blocks.
Send a message both ways on the showcase
#The message
Every message has the same 77-byte header, then the body. Integers are big-endian.
| Offset | Size | Field | From XE | Into XE |
|---|---|---|---|---|
| 0 | 1 | version | 0x03 | 0x03 |
| 1 | 4 | nonce | the sender's outbox index | the origin Mailbox's nonce |
| 5 | 4 | origin | 22599 | e.g. 84532 |
| 9 | 32 | sender | the sending XE account (32 bytes) | the EVM address, left-padded; or the Solana pubkey |
| 41 | 4 | destination | e.g. 84532 | 22599 |
| 45 | 32 | recipient | the EVM address, left-padded; or the Solana program id | the XE account (32 bytes) |
| 77 | n | body | application bytes | application bytes |
The message id is keccak256 of all 77 + n bytes. The body cap is 4,096 bytes in both directions (sys.interop.max_body_bytes).
An XE account is identified by its 32-byte address, never by a key: sha256("xe/account/v1" ‖ ed25519 public key) for a single-key account. That address is the sender of everything the account dispatches.
#From XE to an EVM chain
The account signs a dispatch block. You set the destination, the recipient, the body, an optional gas hint for the recipient's handle, and the relayer's fee. The node fills in the sender, the nonce and the origin.
import { dispatchRequest } from "@xe-network/protocol/interop";import { buildAccountBlock } from "@xe-network/protocol/accounts";import { signCheckedBlock, publicKeyFromSeed } from "@xe-network/protocol/signer"; const request = dispatchRequest({ destinationDomain: 84532, // Base Sepolia recipient: recipientAddress, // an EVM address is widened to 32 bytes body: messageBytes, gasLimit: 200_000n, // hint for the recipient's handle // XE's relayer: 0.25 XE per message (micro-units) relayerFee: { payee: "9a34a351b3a1e2c47b5b7f2408cfc6212458a431c843e0345b5b95beb5a4b1a1", amount: 250_000n },}); const built = buildAccountBlock({ networkId, head, publicKey: publicKeyFromSeed(seed), request, now });const signed = signCheckedBlock(seed, { networkId, block: built.block, signer: { kind: "own" }, hash: built.hash });// add proof of work, then POST /blocks/dispatch on the nodeThe relayer fee is a send inside the same block: it's paid only if the message is dispatched. Then:
- XE confirms the block. Validators sign the checkpoint (Trust model).
- The relayer collects two signatures and calls
Mailbox.process(metadata, message)on the destination. - The Mailbox asks the recipient for its ISM, verifies the signatures with it, and calls
handle(origin, sender, body).
Follow a message at the relayer: GET https://xe-interop-agent.enter-38b.workers.dev/messages/{id}. It moves through dispatched, signing (with signatures.have of threshold), delivering and delivered (with delivery.txHash). It can also end failed, unpaid or unsupported. With the default settings a message reaches Mailbox.process in about 7 seconds.
#Receiving on EVM
A recipient implements Hyperlane's handle and names XE's ISM, so the Mailbox never falls back to its default ISM. XEClient (xe-kit evm/src/xe/XEClient.sol) does both and checks the origin. To accept plain messages from one XE account:
import {XEClient} from "./xe/XEClient.sol";import {XEChains} from "./xe/XEChains.sol"; contract Inbox is XEClient { bytes32 public immutable sender; // the XE account allowed to write here bytes public last; constructor(bytes32 sender_) XEClient(XEChains.baseSepoliaXESim()) { sender = sender_; } function _xeAccepts(bytes32 s) internal view override returns (bool) { return s == sender; } function _onXEMessage(bytes32, bytes calldata body) internal override { last = body; // keep handlers cheap and bounded }}A reverting handle reverts the delivery. The Mailbox keeps the message undelivered and anyone can relay it again.
#From an EVM chain to XE
Call the Mailbox with the XE account as recipient. Pass the MerkleTreeHook explicitly, so the message always enters the tree Hyperlane's validators sign, and pay exactly the quoted fee.
uint256 fee = mailbox.quoteDispatch(22599, xeAccount, body, "", merkleTreeHook);mailbox.dispatch{value: fee}(22599, xeAccount, body, "", merkleTreeHook);The fee is the Mailbox's protocol fee only: 0 on Base Sepolia and Arbitrum Sepolia, 1 wei on Optimism Sepolia. XE has no interchain gas paymaster, so the quote never includes delivery gas. Always quote: Hyperlane governance can change the fee.
From a wallet or a script, the same call as calldata:
import { mailboxDispatchToXeCalldata, quoteDispatchToXeCalldata } from "@xe-network/protocol/interop"; const args = { xeDomain: 22599, recipient: xeAccount, // 64 hex body: messageBytes, merkleTreeHook: "0x86fb9F1c124fB20ff130C41a79a432F770f67AFD", // Base Sepolia};const quoteData = quoteDispatchToXeCalldata(args); // eth_call the Mailbox with thisconst data = mailboxDispatchToXeCalldata(args); // send to the Mailbox with value = the quoteThen:
- Hyperlane's validator for the origin signs the checkpoint.
- XE's relayer finds the message, collects the signature and serves it at
GET /inbound/{xeAccount}withstatus: "ready"and adeliveryobject. That takes about 7 to 10 seconds. - The recipient's wallet signs a
message_receiveblock carrying exactly that delivery. The recipient can also use a delegate key with the RECEIVE permission.
const item = (await (await fetch(`${AGENT}/inbound/${account}`)).json()).messages.find((m) => m.id === id);const d = item.delivery; // { ism_version, statechain_index, message, metadata } const built = buildAccountBlock({ networkId, head, publicKey, request: { op: "message_receive", ismVersion: d.ism_version, statechainIndex: BigInt(d.statechain_index), message: d.message, metadata: d.metadata, }, now,});The message stays in the list until the node reports it delivered: true. Read an account's received messages from the node at GET /interop/inbox/{account}?confirmed=true.
A message into XE carries data only. To make an XE account act on a message, send it to that sender's remote account instead.
#From XE to Solana
The same dispatch, with destination 1399811151 and the recipient program's id as the 32-byte recipient. The relayer calls the Solana Mailbox's process in one transaction with the ISM metadata.
A recipient program implements Hyperlane's four recipient instructions. xe-echo (7q9XXj8ncNryTKjUu4KUNchBfAWvMXAu6bMx8XAaCeZn) is a minimal one. Its handle:
fn handle(program_id: &Pubkey, accounts: &[AccountInfo], h: HandleInstruction) -> ProgramResult { let it = &mut accounts.iter(); // Only the Mailbox can sign for its process authority, and only after the ISM verified the message. let authority = next_account_info(it)?; let (expected, _) = mailbox::process_authority(&MAILBOX, program_id); if authority.key != &expected || !authority.is_signer { return Err(EchoError::NotMailbox.into()); } if h.origin != XE_DOMAIN { return Err(EchoError::WrongOrigin.into()); } // h.sender is the XE account; h.message is the body Ok(())}Its ISM getter returns XE's ISM as a constant, so the Mailbox never uses its default ISM:
RecipientInstruction::InterchainSecurityModule => { set_return_data(&borsh::to_vec(&Some(ISM)).unwrap()); Ok(())}Rules that keep a recipient safe: take no payer in handle (Hyperlane's relayer refuses that), refuse extra accounts, and check the process authority and the origin first.
#From Solana to XE
A wallet or program calls the Mailbox's OutboxDispatch with destination 22599 and the XE account as recipient. The sender is the wallet's pubkey, or, for a program, the program id: the program signs with its dispatch authority PDA (["hyperlane_dispatcher", "-", "dispatch_authority"]). xe-solana-sdk wraps the CPI as mailbox::dispatch (Solana programs).
From there it is the same as from EVM: Hyperlane's devnet validator signs, the relayer serves the message at /inbound/{account}, and the recipient's wallet signs message_receive.
#Limits
| Limit | Value |
|---|---|
| Body, both directions | 4,096 bytes |
| Body to Solana | about 600 bytes in practice |
| Relayer fee, XE to any chain | 0.25 XE per message |
| Relayer fee, into XE | none on XE; relayers are paid off-band |
| Order | Messages are not ordered. Make them independent or wait for one before sending the next |