Solana programs using XE
xe-solana-sdk gives a Solana program its own XE account, sends it commands through the Mailbox, takes receipts by push and results by attestation.
xe-solana-sdk is the Solana equivalent of XE.sol. It's a Rust library, not a program: everything runs inside your program, so your program's own Mailbox sender owns its XE account. There's no shared helper, no storage and no admin.
Status: on Solana devnet with XE Sim Interop. The crate lives in xe-solana crates/xe-solana-sdk. Programs build with Hyperlane's toolchain (cargo build-sbf --tools-version v1.51).
#Push and claim on Solana
| Push | Claim by attestation | |
|---|---|---|
| Carries | Receipts and other small messages, through the Mailbox's handle | Agreed service results |
| Size | The whole message must fit a Solana transaction: bodies under about 600 bytes | 352-byte attestation, the signatures and the output (the demo takes up to 512 bytes) |
| Verified by | XE's ISM, through the Mailbox | Your program, with secp256k1_recover against the validator set XE's ISM holds |
| Who pays | The relayer | Whoever calls claim |
A result's onXEResult body is usually too big for a Solana transaction, so results reach Solana by attestation. Receipts are 72 bytes and are pushed.
#The program's XE account
use xe_solana_sdk::{remote_account, SOLANA_DEVNET_DOMAIN}; // sha256("xe/remote-account/v1" ‖ 1399811151 ‖ program_id ‖ 0)let account: [u8; 32] = remote_account(SOLANA_DEVNET_DOMAIN, &program_id);Fund it on XE in the service's price asset before you ask. Anyone can send to it, and anyone may publish its receive.
#Sending a command
Commands are byte for byte what the node decodes, the same as XE.sol's. mailbox::dispatch sends one with a Mailbox OutboxDispatch CPI signed by your program's dispatch authority PDA, so the message's sender is your program. It returns the message id, which is the command id.
use xe_solana_sdk::command::{self, Options, ServiceRequest};use xe_solana_sdk::mailbox::{dispatch, DispatchAccounts}; let request = ServiceRequest { service_id: SERVICE_ID, selection: command::SELECTION_BEACON, // see below deadline: (now + 900) as u64, max_price: MAX_PRICE, asset: command::ASSET_XE, n: 0, k: 0, // 0, 0: the service's own rule delivery_mode: command::DELIVERY_ACCOUNT, // the result stays on XE; claim it by attestation destination: 0, recipient: [0; 32], gas_limit: 0, relayer: [0; 32], relayer_fee: 0, data: input.clone(), // inline input; keccak256(input) becomes the attestation's subject};let body = command::encode_service_request( &request, &Options { flags: command::RECEIPTS, deadline: (now + 900) as u64, receipt_gas_limit: 0 },).map_err(|_| ProgramError::InvalidInstructionData)?; let accounts = DispatchAccounts { mailbox, outbox, dispatch_authority, system_program, spl_noop, payer, unique_message, dispatched_message,};let command_id = dispatch(program_id, &accounts, XE_DOMAIN, remote_account(LOCAL_DOMAIN, program_id), body)?;The SDK also has command::encode_pay for payments.
#Receiving the receipt
Your program implements Hyperlane's recipient instructions (Messaging). In handle, check the Mailbox's process authority, the origin and that the sender is your own XE account, then decode the receipt:
use xe_solana_sdk::receipt::{decode_receipt, CODE_EXECUTED}; let authority = next_account_info(it)?;if authority.key != &mb::process_authority(&MAILBOX, program_id).0 || !authority.is_signer { return Err(DemoError::NotMailbox.into());}if h.origin != XE_DOMAIN { return Err(DemoError::WrongOrigin.into());}if h.sender != remote_account(LOCAL_DOMAIN, program_id) { return Err(DemoError::WrongSender.into());}let Some(r) = decode_receipt(&h.message) else { msg!("not a receipt: ignored"); return Ok(()); // never block the Mailbox on an unexpected body};if r.op == command::OP_SERVICE_REQUEST && r.code == CODE_EXECUTED { // r.executed_in is the XE request block: the request id the attestation will name}#Claiming the result
The validator set comes from XE's ISM: its domain-data account for origin 22599, owner-checked. Reading it there means a validator rotation on the ISM needs no second configuration.
use xe_solana_sdk::{attest::Attestation, ism::ValidatorSet}; // In claim(attestation, signatures, output):let a: &Attestation = &c.attestation;if a.service_id != SERVICE_ID { return Err(DemoError::WrongService.into());}// a request this program made, whose receipt said executedlet slot = state.slots.iter_mut() .find(|s| s.status == EXECUTED && s.request_id == a.request_id) .ok_or(DemoError::UnknownRequest)?;if a.subject != slot.subject { return Err(DemoError::WrongSubject.into()); // keccak256 of the input we asked about}if c.output.len() > MAX_OUTPUT || !a.output_matches(&c.output) { return Err(DemoError::WrongOutput.into()); // SHA-256 of the output}let set = ValidatorSet::from_account(domain_data, &ISM, XE_DOMAIN) .map_err(|_| DemoError::WrongIsmAccount)?;a.verify(&c.signatures, &set, Clock::get()?.unix_timestamp) .map_err(|_| DemoError::BadAttestation)?;// record the result once (the demo writes it to ["result", request_id])Attestation::verify checks the set id, the network, the expiry and exactly threshold signatures by distinct members in ascending order, with low s and v of 27 or 28. It checks nothing about the service, the subject or the output: your program does.
XE's attestation digest is EIP-712 with no chain id and no contract, so the same signatures verify on Solana unchanged.
#The consumer demo
xe-consumer-demo (BPZnTqFFBkAr1GnXrtU9StQAHB5uyQhzif7H55KSApt7) asks xe-test.uppercase from its XE account, takes the receipt by push and the result by attestation, as XEPullConsumer does on EVM.
| Instruction | What |
|---|---|
Ask(input) | Sends the request through the Mailbox as the program. Stores the command id and keccak256(input) in a slot |
handle | The receipt: the slot records the request id, or the failure |
Claim(attestation, signatures, output) | Checks the attestation as above, writes the output to ["result", request_id] |
Anyone may ask, so the program caps what a stranger can spend of its XE: at most 10 micro-XE escrowed per ask, at most 24 asks per UTC day, and none while all eight slots are in flight. When no slot is free, an ask evicts the oldest executed but unclaimed outcome. Claim soon after the receipt.
One run on devnet (2026-10-18):
| Step | Link | From the ask |
|---|---|---|
| Ask on Solana | 2D1yhMgw… | 0 s |
| The request on XE | a99e1e7a… | 13.6 s |
| Settled on XE, agreed by 3 providers | 25.1 s | |
| The receipt delivered on Solana | 2ZispgVC… | 25.4 s |
| Claimed by attestation | 3JeNibjL… | 30.5 s |
#SDK modules
| Module | What |
|---|---|
remote_account | The program's XE account |
command | encode_header, encode_pay, encode_service_request, ops, flags, assets |
mailbox | dispatch: the OutboxDispatch CPI as the program |
receipt | decode_receipt for the 72-byte XERR receipt |
attest | Attestation (borsh), digest, verify, output_matches, is_beacon, check_signatures |
ism | ValidatorSet from XE's ISM domain-data account, domain_data_address, the set id |
feeds | decode_report for compute feed reports (Price feeds) |