IM/VOUCHER/1
A voucher says: on this channel, the buyer has accepted settled_total micro-USDC in total, covering the receipts committed to by receipts_commitment. It is cumulative, so a later voucher replaces an earlier one, and anyone may relay it to the program.
Layout
IM/VOUCHER/1: 168 bytes, little-endian, no padding between fields.
| Offset | Size | Field | Type | Meaning |
|---|---|---|---|---|
| 0 | 16 | tag |
bytes[16] |
IM/VOUCHER/1 right-padded with 0x00 to 16 bytes. |
| 16 | 64 | domain |
bytes[64] |
genesis_hash ‖ program_id. redeem requires the program's compiled GENESIS and its own program id. |
| 80 | 32 | channel |
bytes[32] |
Channel account address. redeem requires it to equal the channel being redeemed. |
| 112 | 8 | channel_epoch |
u64 |
Must equal the channel's channel_epoch. |
| 120 | 8 | seq |
u64 |
Informational. Neither the program nor the gateway orders vouchers by it. |
| 128 | 8 | settled_total |
u64 |
Cumulative micro-USDC the buyer accepts on this channel. At most the channel budget. |
| 136 | 32 | receipts_commitment |
bytes[32] |
Head of the receipts commitment chain after the receipts this voucher covers. |
16 + 64 + 32 + 8 + 8 + 8 + 32 = 168 bytes. A message of any other length is rejected.
<sub>Generated from packages/protocol/src/wire.ts, crates/im-protocol/src/wire.rs, crates/im-protocol/vectors/generate.py.</sub>
Redemption rule
redeem pays settled_total − redeemed to the channel's seller_payout_token when settled_total > redeemed, then sets redeemed = settled_total. A voucher at or below redeemed succeeds without a transfer, so relays can retry safely. settled_total may never exceed the channel budget (ChannelBudget), and redemption is allowed only while the close deadline D is unset or now < D (DeadlinePassed).
The program also requires, from the voucher bytes (InvalidVoucher otherwise): the IM/VOUCHER/1 tag and exact length, a domain equal to its compiled GENESIS and its own program id, channel equal to the channel account, and channel_epoch equal to the channel's epoch. seq is ignored.
Ed25519 proof
The program does not verify the signature itself. The instruction immediately before redeem in the same transaction (current_index − 1) must be a call to the Ed25519 signature-verification precompile (Ed25519SigVerify111111111111111111111111111) whose data begins with this 16-byte header, all integers little-endian (A24):
| Bytes | Field | Required |
|---|---|---|
| 0 | num_signatures (u8) |
1 |
| 1 | padding | any |
| 2–3 | signature_offset (u16) |
at least 16; 64 bytes there in the same instruction data |
| 4–5 | signature_instruction_index (u16) |
0xFFFF (this instruction) |
| 6–7 | public_key_offset (u16) |
at least 16; the 32 bytes there equal the channel's session_key |
| 8–9 | public_key_instruction_index (u16) |
0xFFFF |
| 10–11 | message_data_offset (u16) |
at least 16; the 168 bytes there equal voucher_bytes |
| 12–13 | message_data_size (u16) |
168 |
| 14–15 | message_instruction_index (u16) |
0xFFFF |
Anything else fails with MissingSignature. The canonical proof is 280 bytes: the header [1, 0, 48, FFFF, 16, FFFF, 112, 168, FFFF], the public key at 16, the signature at 48 and the voucher at 112.
Acknowledgment by the seller
Before relaying, a buyer posts the voucher to the seller's gateway, POST /im/v1/vouchers, with the receipts it covers:
{ "voucher": "<base64 of 168 bytes>", "sig": "<base64 of 64 bytes>", "receipts": ["<base64 of 382 bytes>", "..."] }
The gateway accepts it only if:
- the voucher is for one of its channels (domain, epoch, settler and payout match) and verifies under the channel's
session_key; settled_total ≤ budgetand is not below what was already acknowledged or redeemed;- each receipt was issued by this gateway on this channel and not yet acknowledged, and the receipts are in canonical order with no duplicates;
- the sum of their charges equals the delta since the last acknowledged voucher (A13);
- the commitment chain continued from the last acknowledged commitment ends at
receipts_commitment.
It answers {"ack": true, "settled_total": <integer>}. Posting the identical voucher and receipts again returns the same acknowledgment. The buyer chooses which receipts a voucher covers; the seller cannot demand completeness, and protects itself only by refusing new Holds once its unvouchered exposure would exceed the channel's funds (A25′). Errors are listed under Error codes.
The seller's settler batches acknowledged vouchers and redeems them on-chain.