DIM · Dagon Inference Marketplace

IM/HOLD/1

A Hold asks a seller to serve one request on one channel, at a stated route and price schedule, for at most cap_micros. The buyer signs it with the channel's session_key and sends it in the headers of the chat request. A Hold moves no money: the program only pays out on a voucher, and its decoder rejects any other tag.

Layout

IM/HOLD/1: 275 bytes, little-endian, no padding between fields.

Offset Size Field Type Meaning
0 16 tag bytes[16] IM/HOLD/1 right-padded with 0x00 to 16 bytes.
16 64 domain bytes[64] genesis_hash ‖ program_id. Must equal the gateway's configured domain.
80 32 channel bytes[32] Channel account address.
112 8 channel_epoch u64 Must equal the channel's on-chain channel_epoch.
120 2 lane u16 Buyer-chosen lane. Counters are tracked per (channel, lane).
122 8 lane_counter u64 Strictly increases per (channel, lane) (A6); otherwise 402 lane_replay.
130 32 request_id bytes[32] Random per attempt. Unique seller-wide; otherwise 402 duplicate_request.
162 32 request_commitment bytes[32] SHA256(salt32 ‖ exact HTTP body bytes); the salt travels in X-IM-Salt (A19).
194 32 route_id bytes[32] A route in the seller's signed listing; otherwise 402 route_mismatch.
226 32 schedule_digest bytes[32] SHA256(jcs(schedule)) of the route's effective schedule; otherwise 402 schedule_mismatch.
258 8 cap_micros u64 Most the buyer will pay for this request, in micro-USDC. At least w_req_micros, at most the per-request limit.
266 8 dispatch_until i64 Unix seconds. The gateway rejects the Hold once dispatch_until < now (402 hold_expired).
274 1 tape_consent u8 Always 0 in the MVP. Decoders reject any other value (TapeConsent).

16 + 64 + 32 + 8 + 2 + 8 + 32 + 32 + 32 + 32 + 8 + 8 + 1 = 275 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>

Transport

The Hold rides on POST /v1/chat/completions (see Seller HTTP API):

Header Value
X-IM-Hold base64 of the 275 Hold bytes
X-IM-Hold-Sig base64 of the 64-byte Ed25519 signature by the session key
X-IM-Session base58 of the session public key
X-IM-Salt base64 of the 32-byte salt in request_commitment

The body must be byte-for-byte the bytes the buyer committed to: request_commitment = SHA256(salt ‖ body). The gateway hashes the body it actually received and refuses a mismatch with 402 malformed_hold. Nobody re-serializes the body (A19).

Admission checks

The reference gateway checks the following and answers the first failure with HTTP 402 and {"error": {"code", "message"}}. This is the order of its single-process ledger; the shared multi-process ledger runs steps 8, 10 and 11 when it claims the request.

  1. The headers decode to exact lengths, the domain is the gateway's, and the signature verifies under the channel's session_key (malformed_hold, unknown_channel, bad_signature).
  2. The route is listed here (route_mismatch).
  3. The channel is known, its epoch matches, it is Open with no close deadline and before its service end T (unknown_channel, malformed_hold, channel_closed).
  4. The channel pays this seller: its seller_settler and seller_payout_token match the listing (wrong_seller).
  5. schedule_digest is the route's schedule and that schedule is in effect (schedule_mismatch).
  6. dispatch_until ≥ now (hold_expired).
  7. cap_micros ≥ w_req_micros (cap_too_low).
  8. request_id was never admitted and lane_counter is higher than the last one on this (channel, lane) (duplicate_request, lane_replay).
  9. cap_micros is within the per-request limit: the Mandate's per_request_cap for a delegated channel, otherwise budget − redeemed (cap_exceeds_limit, A7).
  10. The cap fits the channel's uncommitted funds, budget − max(redeemed, acknowledged) − unvouchered − in flight (insufficient_channel_funds, the only retryable code).
  11. The route has a free concurrency slot; otherwise HTTP 429 no_headroom with Retry-After: 1.

The full list of codes is on Error codes. A request that gets any non-2xx answer is unbillable: a receipt later presented for its request_id must be failed or not_served with charge 0 (A22, A29).