The Agentic Transaction Record
What an ATR is, and how assemble writes its exact bytes.
For AI agents: this page as Markdown, and llms.txt, the index of every page.
An Agentic Transaction Record (ATR) is the agreement's record: the exact bytes the seller serves and the buyer
fetches before it pays; assemble writes them as one JSON object. Where the payment the buyer approves carries the
ATR's hash, that approval is the buyer's acceptance of that exact record; where it does not, the pairing's
data.proves says so.
This package decides nothing about what an ATR says. It fixes only three things: a format marker, a per-transaction identifier, and the values that tie the record to one payment. Everything else is the parties' content, carried exactly as given.
The byte layout
assemble writes one UTF-8 JSON object with its members in a fixed order:
| Position | Member | Value |
|---|---|---|
| 1 | atrVersion | Always the string "1". |
| 2 | id | The per-transaction identifier you pass, as a JSON string. newAtrId() gives a random RFC 9562 version 4 UUID. |
| 3 | the binding slot | The values that tie this record to one payment, written with JSON.stringify. The pairing's tie gives the slot: x402 for x402, mpp for MPP, and so on. |
| 4 onward | the party slots | Each party slot's bytes, exactly as received, in the order given. |
The party slots are never parsed into values, re-serialised or canonicalised. assemble checks only that each one
holds exactly one JSON value in well-formed UTF-8 that two JSON readers read alike, then copies its bytes. A seller that stores the returned bytes and
a buyer that fetches them hash the same thing.
Assembling an ATR
This example assembles the ATR of the package's first core vector, and prints its bytes and its hash:
import { , } from "@integraledger/lcp";
const = new ();
const = await (
"6f1c2b0e-8d4a-4c3b-9e2f-1a7d5c9b3e40",
["bind", { : "v", : 7, : ["a", "b"] }],
[
["terms", .('"Pay 10000 base units of USDC for one report."')],
["seller", .('{"name":"Acme Reports"}')],
],
);
if (()) throw new (.);
.(new ().(.));
.(.);{"atrVersion":"1","id":"6f1c2b0e-8d4a-4c3b-9e2f-1a7d5c9b3e40","bind":{"k":"v","n":7,"list":["a","b"]},"terms":"Pay 10000 base units of USDC for one report.","seller":{"name":"Acme Reports"}}
0xf693f8353bd93131403120d11e849c7646ad8976857560b9f72ac2ebe08de12fThe same inputs always give the same bytes. A party slot keeps its own spacing and member order: a slot received as
{ "b": 1, "a": 2 } is written with that spacing and in that order.
The rules assemble enforces
assemble(id, binding, content, limits?) returns { bytes, atrHash }, or a refusal that names the
first rule an input breaks. It checks limits.maxBytes first (one that is not a safe integer of at least 0 is
core/too-large), then id, the shapes of binding and content, the binding slot's name, the number of party
slots, each party slot in turn (its shape, its name, and that its bytes are a Uint8Array), the binding value, the
record's size, and last the JSON each party slot holds:
| Rule | Refusal |
|---|---|
id is a string. | core/binding-not-json |
binding is an array of two, the slot name and the value, and so is each party slot in content, the name and the bytes. | core/slot-name |
content is an array. | core/content-not-json |
Every slot name matches ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$: at most 64 characters, MAX_SLOT_NAME_LENGTH from the package root. | core/slot-name |
No slot is named atrVersion or id, and no party slot takes the binding slot's name. | core/slot-reserved |
| No two party slots share a name. | core/slot-duplicate |
Each party slot's bytes are a Uint8Array of well-formed UTF-8 without a byte-order mark, and hold exactly one JSON value (RFC 8259) nested at most 64 levels deep, in which no object repeats a member name (names compared after their escapes are decoded), no number overflows a double, and no integer lies beyond 2^53 - 1 either way; a number beyond the safe integers is written as a string. | core/content-not-json |
The binding value is a JSON value that JSON.stringify writes exactly: every number a safe integer, every string free of unpaired surrogates, nested at most 64 levels deep. | core/binding-not-json |
At most 64 party slots, and the whole record at most limits.maxBytes bytes (1 MiB by default, and never more than 1 MiB, MAX_ATR_BYTES from the package root). | core/too-large |
assemble reads each input once, each member of the binding value included, in the one walk that checks the binding
value and writes it. The value read from an input behind an accessor is the value checked and written, and toJSON
is never called.
Who stores it
The ATR is delivered, not kept by this package. The seller writes the bytes to its own storage and serves them at an
https link, and the buyer keeps its own copy. assemble holds nothing after it returns.
Next
- The ATR hash: the hash of these bytes, and the forms it is written in.
- Binding: how the hash rides in a payment.
Last updated on