Vouchers
A voucher is the only payable message in DIM: a 168-byte note, signed by the channel's session key, that says "the total I accept owing on this channel is now X." The seller can take it to the Solana program and collect X minus whatever it already collected. Because each voucher carries a running total rather than an amount, sending the same voucher twice pays nothing extra, and a newer voucher replaces all older ones.
What is in a voucher
| Field | Meaning |
|---|---|
| tag, domain | IM/VOUCHER/1 and genesis_hash ‖ program_id. |
channel, channel_epoch |
Which channel. |
seq |
A sequence number; informational. |
settled_total |
Cumulative micro-USDC the buyer has accepted on this channel. |
receipts_commitment |
A hash chain over every receipt this total covers. |
Running totals
Each voucher's new money, its delta, is settled_total minus the last total the seller acknowledged, starting from 0. The delta must equal the exact sum of the charges on the receipts it covers.
Example: three receipts charge 771, 412 and 1,050 micro-USDC. The first voucher covers the first two and says settled_total = 1,183. The next covers the third and says settled_total = 2,233. If the seller redeems only the second, it is still paid 2,233 in total.
The receipts commitment
The commitment ties a voucher to the exact receipts it pays for:
C0 = SHA256("IM/EMPTY/1")
Ci = SHA256("IM/APPEND/1" ‖ C(i−1) ‖ SHA256(receipt_bytes))
Receipts in one voucher are appended in a canonical order: ascending created_at, then request_id bytes. Each voucher continues the chain from the last acknowledged commitment, so the whole history of a channel is one unbroken chain.
You choose what to pay for
The buyer decides which receipts each voucher covers. A voucher may cover any batch of receipts that are previously unacknowledged, issued on that channel, in canonical order, with a delta equal to their charges. The seller cannot demand completeness. Its only protection is to stop admitting new holds once its unvouchered exposure would exceed what the channel has left (402 insufficient_channel_funds), or to close the channel.
Delivering a voucher
The buyer posts it to the seller:
POST /im/v1/vouchers
{ "voucher": "<base64 168 bytes>", "sig": "<base64 signature>", "receipts": ["<base64 receipt>", "…"] }
The seller checks that it issued every receipt, that they are unacknowledged and in order, that the commitment matches, that the delta equals their charges and that the total fits the budget. It stores the voucher and answers {"ack": true, "settled_total": …}. Otherwise it answers 400 with a code such as wrong_delta, receipt_order, wrong_commitment, invalid_receipt or over_budget. The seller's settler later redeems the newest voucher on-chain, batched.
The SDK does all of this for you: it batches up to 32 verified receipts per voucher by default, waits about 10 ms to gather a batch, and resends the exact same signed body if a POST's outcome is unknown.