# Integra Protocol: Concepts > The 8 pages of the section Concepts of https://lcp.integraledger.com/llms.txt, in its order. They document @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. # The Agentic Transaction Record > What an ATR is, and how assemble writes its exact bytes. Source: https://lcp.integraledger.com/concepts/atr Updated 2026-11-19. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. 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. | ```mermaid flowchart LR A["atrVersion"] --> B["id"] B --> C["binding slot: the payment's values"] C --> D["party slots: the parties' bytes, untouched"] D --> E["SHA-256 over every byte: H"] ``` 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: ```ts import { assemble, isRefusal } from "@integraledger/lcp"; const utf8 = new TextEncoder(); const atr = await assemble( "6f1c2b0e-8d4a-4c3b-9e2f-1a7d5c9b3e40", ["bind", { k: "v", n: 7, list: ["a", "b"] }], [ ["terms", utf8.encode('"Pay 10000 base units of USDC for one report."')], ["seller", utf8.encode('{"name":"Acme Reports"}')], ], ); if (isRefusal(atr)) throw new Error(atr.code); console.log(new TextDecoder().decode(atr.bytes)); console.log(atr.atrHash); ``` ```text {"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"}} 0xf693f8353bd93131403120d11e849c7646ad8976857560b9f72ac2ebe08de12f ``` The 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](https://lcp.integraledger.com/concepts/refusals.md) 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](https://lcp.integraledger.com/concepts/atr-hash.md): the hash of these bytes, and the forms it is written in. - [Binding](https://lcp.integraledger.com/concepts/binding.md): how the hash rides in a payment. --- # The ATR hash > SHA-256 over the ATR's exact bytes, the forms it is written in, and how two hashes are compared. Source: https://lcp.integraledger.com/concepts/atr-hash Updated 2026-11-18. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. The **ATR hash (H)** is SHA-256 over the ATR's exact bytes: the bytes the seller serves, as they arrive. Nothing is parsed, trimmed or re-encoded before hashing. `hash(bytes)` computes it, and `assemble` returns it beside the bytes it wrote. `hash` takes the bytes as a `Uint8Array` and rejects with a `TypeError` for any other value, a string included. With an `id` from `newAtrId()`, two ATRs with the same terms have different hashes, and H is unpredictable before the seller issues it. ## The forms of H The same 32 bytes are written in four forms. The package writes H in lowercase, except on MPP XRPL, whose `methodDetails.invoiceId` and Payment `InvoiceID` hold H's 64 hex digits in upper case (`mppInvoiceId`). It reads either case, except in five carriers that must hold H's LCP string with lowercase hex exactly; the same hash in another spelling is refused: - a Solana memo (`svm/carrier-not-canonical`), with an x402 option's `extra.memo` and an MPP request's `externalId` (`svm/carrier-mismatch`); - a Cardano CIP-20 message, whose two lines are the string's `lcp:sha256:0x` and its digits (`cardano/hash-not-carried`); - a Polkadot remark (`polkadot/remark-not-lcp`); - the x402 XRPL option's `extra.invoiceId`, whose SHA-256 is the Payment's `InvoiceID` (`xrpl/carrier-mismatch`); - a Concordium memo, which must equal `ccdMemo(h)` (`ccd/memo-not-lcp`). | Form | Example | Written by | Read by | |---|---|---|---| | Hex | `0xba7816bf…f20015ad` | `hash`, `assemble`, every `bound` | `hashEquals` | | LCP string (`LCP §8.1`) | `lcp:sha256:0xba7816bf…f20015ad` | `toLcpString` | `fromLcpString` | | Structured (`LCP §8.1`) | `{"legalContext":{"type":"sha256","value":"0x…","legalContextUrl":"https://…"}}` | `toLegalContext` | `fromLegalContext` | | Raw bytes | 32 bytes | `toRawBytes` | `fromRawBytes` | The structured form puts the link to the seller's copy beside the hash. `toLegalContext(h, url, "snake")` writes the link as `legal_context_url` for protocols that use snake case, and `fromLegalContext` reads either spelling. ```ts import { fromLcpString, hash, hashEquals, toLcpString, toLegalContext, toRawBytes } from "@integraledger/lcp"; const h = await hash(new TextEncoder().encode("abc")); console.log(h); console.log(toLcpString(h)); console.log(JSON.stringify(toLegalContext(h, "https://atr.seller.example/abc"))); console.log(toRawBytes(h).length); const upper = `0x${h.slice(2).toUpperCase()}`; console.log(hashEquals(h, upper), fromLcpString(toLcpString(h)) === h); ``` ```text 0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad lcp:sha256:0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad {"legalContext":{"type":"sha256","value":"0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad","legalContextUrl":"https://atr.seller.example/abc"}} 32 true true ``` ## Comparing two hashes `hashEquals(a, b)` is the one comparison (`LCP §2.5`). It is true only when both strings are `0x` followed by 64 hex digits, in either case, and they decode to the same 32 bytes. Anything else, including a hash in another form, is false. It compares every byte, whatever the first difference. Compare with `hashEquals`, never with `===`: a hash that arrives in upper case is the same hash. ## The agreement's own value On some pairings the buyer pays twice under one H: first an agreement payment, then the full payment ([the agreement URL](https://lcp.integraledger.com/concepts/buyer-gate.md#the-agreement-url)). Where a pairing's single-use value is H itself or H's low bits, such as the EIP-3009 and Permit2 `nonce`, the two payments cannot both carry H, so the agreement carries its own value instead: `agreementValue(h)`, SHA-256 over the 16 ASCII bytes `lcp-agreement-v1` followed by H's 32 bytes, written as H is, or that value's low bits where the pairing takes H's low bits. A pairing's `build(choice, h, "agreement")` writes it, and `bound(presented, { act: "agreement", h })` checks it. A holder of the ATR compares it with what `recover` reads from an agreement's transaction, since a digest is not read back to H. `agreementValue` rejects with a `TypeError` when `h` is not a 32-byte hash. ```ts import { agreementValue, hash } from "@integraledger/lcp"; const h = await hash(new TextEncoder().encode("abc")); console.log(await agreementValue(h)); ``` ```text 0x424524a7e791dcf7c2e6980bc94582ae2b436d6184873563d03539e97d36a434 ``` ## The link The link beside H is an `https` URL that serves the ATR's exact bytes. `isHttpsLink` is the one rule every pairing applies to it: - the string holds no whitespace, control character or backslash; - it parses as an absolute URL whose scheme is `https`, in either case, by the WHATWG URL Standard's basic URL parser; - its authority has a host, a DNS name or an IP literal, and no user information. A pairing's `advertise`, and MPP's and A2A's `place`, refuse any link that fails the rule as `/link-not-https`: the link MUST be `https://` (LCP §8.1). A pairing's `read` refuses a link of another scheme, at most 2048 characters long, as `/link-not-https`, and any other link that fails the rule as `/legal-context-malformed`; card's, ACK's and AP2's `read` refuse every link that fails the rule as `/legal-context-malformed`. The pairings also cap a link at 2048 characters: an `https` link over that is `/legal-context-malformed`, or `/too-large` on ACP, AP2 and UCP. `isHttpsLink`, `toLegalContext` and `fromLegalContext` set no length. The package reads the scheme and the authority of a link with its own copy of the URL Standard's parser, not the runtime's `URL`, so `isHttpsLink` and `isOtherSchemeLink` give one answer on every runtime. Its host parser (`parseHost`) reads a domain with the Standard's domain parser (`domainToAscii`): an ASCII domain is lowercased, and any other is read by UTS #46 ToASCII with the flags the Standard sets, over the Unicode 17.0.0 data the package carries, with its own normalization, Punycode, ContextJ and bidi rule. The path, query and fragment never fail the parse. `readUrl(input)` gives that reading of a string, `{ scheme, host, credentials, port }`: the scheme, lowercased; the serialized host, or null for a URL with no authority; whether it has a non-empty username or password; and the port, or null where it names none or its scheme's default. It gives null where the parser fails. ## The core alone A Worker that needs only the core imports `@integraledger/lcp/core`. It exports the core functions the package root exports, each the root's own function: `assemble`, `newAtrId`, `hash`, `hashEquals`, `agreementValue`, the forms of H and their readers, `isHttpsLink`, `isOtherSchemeLink`, `readUrl`, `parseHost`, `domainToAscii`, `canonicalJson`, `digestJson`, `parseJson`, `fromBase64`, `base64Bytes`, `toBase64`, `fromBase64Url`, `base64UrlBytes`, `toBase64Url`, `isRefusal` and `readToRepeat`. It imports no pairing, no rail and no optional peer, so the Worker's bundle holds the core alone. ```ts import { hash, hashEquals, toLcpString } from "@integraledger/lcp/core"; // SHA-256("abc"), the FIPS 180-2 example. const h = await hash(new TextEncoder().encode("abc")); console.log(toLcpString(h)); console.log(hashEquals(h, "0xBA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD")); ``` ```text lcp:sha256:0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad true ``` ## Next - [Binding](https://lcp.integraledger.com/concepts/binding.md): where H rides in each payment. - [The buyer gate](https://lcp.integraledger.com/concepts/buyer-gate.md): comparing the served bytes with H before signing. --- # Binding > How the ATR hash rides in a payment, the binding patterns, and what each binding proves. Source: https://lcp.integraledger.com/concepts/binding Updated 2026-11-20. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. **Binding** is how H rides in a pairing's payment: the field its specification defines. The seller places H where the protocol or rail provides a place, and, where the pairing's `data.carrier.signed` names a field, the buyer approves a payment that carries H, or carries a value from which anyone holding the ATR can confirm exactly that H. Where its `data.coverage` is `none`, no public act the payer signs carries H, whatever the buyer approves, and the agreement payment is the proof. Binding is what this package checks about a payment, beside the form its rail or scheme requires and the bounds within which it reads its input. It never judges amount, payee, asset, timing or payer, and never reads the parties' content in the ATR. A discrepancy between what the parties agreed and what was paid is between them, and the record is what they agreed to. ## Where H rides Where H rides depends on the pairing. Some examples, all from the package's own pairings: | Pairing | Where H rides | |---|---| | `x402/exact/eip155/eip3009` | The `nonce` of the EIP-3009 authorization the payer signs. | | `x402/exact/solana` | The option's `extra.memo`, written by the payer as the transaction's one Memo instruction. | | `x402/exact/xrpl` | The Payment's `InvoiceID`, which is SHA-256 of H's LCP string, in a Payment the payer signs with a single key. | | `mpp/charge/evm/authorization` | The MPP challenge `id`, from which the signed nonce is derived. | | `x402/batch-settlement/eip155` | The channel configuration's `salt`, which every signature in the channel signs. | | `card/visa-tap` | The `nonce` of every `agent-payer-auth` message signature of the agent's request, the base64 of H and 32 random bytes, or the checkout path those signatures cover. | The [pairings reference](https://lcp.integraledger.com/reference/pairings.md) gives every pairing with the sentence its record states. ## The patterns Every pairing has a binding record, `pattern`, and every one but `x402/exact/starknet` names its binding pattern in `pattern.pattern`. The five this package's pairings use: | Pattern | What it means in this package's pairings | |---|---| | `native-field` | H itself, or its LCP string, sits in a field the protocol or rail defines: a nonce, memo, note, remark, salt, session id or invoice field. | | `id-reuse` | An identifier the payment already carries is derived from H: MPP's challenge id through the signed nonce, an escrow's salt, the XRPL `InvoiceID`, or a card checkout's hash. | | `opaque-challenge` | H rides in the challenge or checkout the seller issues, and what the buyer presents echoes it or commits to it. | | `protocol-extension` | H rides in a protocol extension: a field the agent's message signature covers, or an extension echoed on each request. | | `http-advisory` | H and its link are advertised in the exchange, and nothing the buyer signs or the rail carries holds H. | The `LcpPattern` type also names `overlay-contract` and `sidecar-attestation`. No pairing in this package uses them. These names are this package's. `LCP §8.3` defines six settlement binding patterns: Native Field, Overlay Contract, Sidecar Attestation, Opaque Challenge Parameter, Id-Reuse (Hashed Binding) and Protocol Extension. `http-advisory` is the HTTP-Layer Advisory Reference of `LCP §8.3.7`, which "is not one of the six patterns above; it is the no-binding baseline". ## What each binding proves Each pairing's `pattern` record names its binding pattern and where the binding is seen: | Field | Meaning | |---|---| | `pattern` | The binding pattern above, where one of them names the binding. | | `onChain` | The binding is visible on a public ledger after settlement (`LCP §8.3`): the settlement carries H or a value derived from it. | | `zeroPartyRecoverable` | H can be read back from the settled transaction alone, without either party (the pairing's `recover`). | | `forwardIndexable` | A search by H finds the settlement. | | `profile` | The LCP profile that defines the binding, where one does. The profiles ship in the package's [`profiles/`](https://lcp.integraledger.com/profiles/llms.txt). | Each pairing's `data` states what a payment through it shows, and never claims more. Its members are plain values, typed `PairingData`: | Member | Meaning | |---|---| | `coverage` | `full`: the payer's own signed act, on a public ledger, binds all of H, a 256-bit digest over a preimage that holds H, or on Starknet H's low 250 bits. `none`: no public payer-signed act carries H. | | `carrier` | `signed`, the field of what the payer signs that carries H, or null; `member`, the path of the option or request member the seller writes H into, where it writes one. | | `link` | At coverage `none`: whether the payment carries H (`h`), a pointer to its proof transaction (`pointer`), or neither (`none`), in a field that is no public proof. | | `source` | Who writes H: lcp's client, or a stock client and release, with the member it copies H from. | | `nonce` | Whether the identical instrument can land more than once: `single-use`, `reusable`, or `unshown` until a vector or a run shows single use. | | `broadcasts` | The answers the pairing's `broadcaster` can give: `payee`, `payer` or `either`. | | `read` | What a read of the pairing needs: the endpoint kind, the search key and its bound, the history, the contracts and, where the profile or the package states them, the networks each is deployed on (`chains`, CAIP-2 ids keyed by the contract), the signed fact after which the payment can no longer land, and, where the rail bounds it, how long a signed payment stays payable. | | `destination`, `asset`, `payer` | How each is identified in the landed transaction. | | `payeePreconditions` | Where the profile states them: what the payee's account must hold or be on chain before a payment can reach it, such as a token association or an asset already held. | | `option` | Where the pairing's option filter requires members of the option's `extra` to hold fixed values: `extra`, each such member with its value, as the profile states them, so a resource server writes them into its option. For example `x402/exact/stellar/precondition`'s is `{ assetTransferMethod: "lcp-precondition", areFeesSponsored: true }`. | | `cardLike` | `true` where the payment is card-like: a card, checkout or processor payment on no network a CAIP-2 id names. Lightning's pairings, on an `lnbtc` network, do not have it. | | `agreementOn` | At coverage `none`: which agreement the charge can follow: `any`, one on the `same-network`, or one pairing's. | | `confirmed` | Whether something outside this package has shown the form as its profile defines it. | | `agreement` | Where the pairing's payment can itself be an agreement: the smallest amount, who pays the fee (`fee`, and as data `feePayer`: the parties that may pay it, `buyer`, `settler`, `paymaster` or `none`, and the one that pays where the option names none), and the fields that show it succeeded. | | `proves` | One paragraph stating what the payment shows and what it does not. At coverage `none`, it opens with the agreement payment the buyer gate requires before the full payment, and the record fills in that payment's `` and ``. | Where the buyer's approval does not sign H, the record says so, and says what the payment does show. For example, `x402/exact/eip155/erc7710`, whose `data.carrier.signed` is null, states (the record fills in `` and ``): > Before this payment was taken, an account signed an agreement transaction carrying this ATR's hash on , > recorded in ; this shows neither that the account is the payer nor what the agreement moved. The ATR was > assembled and delivered before the payment, and the payment payload echoed this ATR's hash in the legalContext entry > of x402's extensions. The read found the named settlement transaction, after the agreement's position, holding a > transfer from the payment's delegator to the payee. The delegation does not sign the hash, and the settlement > transaction does not carry it. This example checks that some pairings' buyer does not sign H, `mpp/charge/stripe` among them: ```ts import { BINDINGS } from "@integraledger/lcp"; const unsigned = BINDINGS.filter((b) => b.data.carrier.signed === null).map((b) => `${b.id} (${b.data.coverage})`); console.log(unsigned.length > 0, unsigned.includes("mpp/charge/stripe (none)")); ``` ```text true true ``` ## Binding the request too On x402, the ATR's binding slot also records the request the challenge answers: its method, path, query and a SHA-256 of its body (`requestCommitment`), beside every option the challenge offers, exactly as issued (`tie`). On MPP, the binding slot records every challenge's bound parameters as issued, including the body's `digest` when the seller sets one; MPP binds no HTTP method, path or query. H therefore commits to the payment options and the request, as well as to the parties' content. ## Next - [Pairings](https://lcp.integraledger.com/concepts/pairings.md): the members of a pairing. - [Rails](https://lcp.integraledger.com/guides/rails.md): where H rides on each chain and on Lightning. --- # Pairings > A payment protocol, scheme and rail combination, the members every pairing has, and the registry. Source: https://lcp.integraledger.com/concepts/pairings Updated 2026-11-18. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. A **pairing** is a payment protocol, scheme and rail combination, such as `x402/exact/eip155/eip3009`. Its id reads from the protocol outward: the surface (`x402`), the scheme or intent (`exact`), then the rail and its method (`eip155`, `eip3009`). Each pairing is one frozen object that carries the whole binding for that combination, on both sides of the payment. The package holds the pairings of eight surfaces: `x402`, `mpp`, `acp`, `ucp`, `ap2`, `ack`, `card` and `spend-permissions`. The [pairings reference](https://lcp.integraledger.com/reference/pairings.md) lists each one, and their count, generated from the registry. ## The members Every pairing has these members, except `build`, which is absent where the payer's own client builds the payment and the package builds nothing: on `mpp/charge/nearintents`, `mpp/charge/tempo/split-memo`, `mpp/charge/tempo/split-memo/push`, `mpp/session/hedera/stock`, `mpp/session/solana/stock`, `mpp/session/xrpl/stock`, `mpp/subscription/solana` and `x402/upto/xrpl`. Check that `build` is defined before you call it on a pairing taken from `BINDINGS`. The types differ per surface; the roles do not. | Member | Side | What it does | |---|---|---| | `id` | both | The pairing's id. | | `pattern` | both | The [binding record](https://lcp.integraledger.com/concepts/binding.md#what-each-binding-proves): the binding pattern and where the binding is seen. `x402/exact/starknet`'s names no binding pattern. | | `data` | both | The pairing's [data](https://lcp.integraledger.com/concepts/binding.md#what-each-binding-proves), plain values typed `PairingData`: its coverage, where H rides, who writes it, what a read needs and what a payment through this pairing proves (`data.proves`). | | `claims` | seller | `true` when what the buyer presents carries a value bound to H that `bound` reads; `false` when it does not, and a seller has nothing in the payment itself to match. | | `unplaced(option)` | seller | The option as the seller issued it, before the pairing's carrier was placed in it. | | `tie(...)` | seller | The ATR's binding slot: `[slot, value]`, the values that tie the record to this payment. | | `advertise(doc, h, link, offer, ...rest)` | seller | A copy of the challenge or checkout with H, the link and, where the pairing has one, the carrier placed. `rest` is the surface's: `agreementUrl?` on x402 and the checkout and card pairings; `position, act?, agreementUrl?` on MPP; `coinsPerUtxoByte, agreementUrl?` on `x402/exact/cardano`; `error?` on `spend-permissions/eip155`. | | `read(doc)` | buyer | H, the link, the agreement URL when one is present, and the options from an advertised document: on x402, those this pairing can pay; on MPP, every challenge, whatever its method, and `build` refuses another method's challenge. | | `build(choice, h, act?)` | buyer | What the buyer's signer signs, with H in its place, and a `complete` that turns the signature into the payment. For the act `"agreement"`, on a pairing whose single-use value is H itself or H's low bits, the agreement's own value, [`agreementValue(h)`](https://lcp.integraledger.com/concepts/atr-hash.md#the-agreements-own-value), takes H's place. | | `bound(presented, given?)` | seller | H as it appears in what the buyer presented. Given `{ act: "agreement", h }` on such a pairing, it checks that the agreement's own value stands in H's place, and gives H where it does. | | `broadcaster(presented)` | seller | Who broadcasts what the buyer presented: `"payer"`, which sent it before presenting it, or `"payee"`, which sends or executes it after ([Who broadcasts](https://lcp.integraledger.com/concepts/pairings.md#who-broadcasts)). | Pairings that settle on a rail the package can read also have: | Member | What it does | |---|---| | `reference(presented, option, given?)` | The read keys of a payment: its network, the payer and the single-use value the payer signed, by which a read finds the payer's own act, and the option's payee, taken from `option`, the x402 option or MPP challenge the payment answers. The payee is the key of the read's two party tests, never a search key. Given `{ act: "agreement", h }` on a pairing whose agreement has its own value, the single-use value it names is that value. | | `status(ref, reader, query)` | The read of the act `query` asks about, `payment` or `agreement`, through a bounded reader you supply, at the finality `query` asks for; `query` also takes, where you have them, a final position the transaction must come after (`after`), the search position an earlier answer returned (`search`), and other acts under the same H (`others`). It answers `settled`, `pending`, `failed` or `unreadable`, with one reason of a closed list, what it read, and the foreign items it met: transactions that carry H and are not the act, each with its reason. The [read-status profile](https://lcp.integraledger.com/profiles/read-status.md) states the answers, their reasons and the rules that choose them. | | `recover({ network, tx, option }, reader)` | H read back from a landed transaction, for any holder of an ATR and a transaction id; `option` is the x402 option or MPP challenge the ATR's binding slot holds, from which the read takes what it needs. | | `authorizer(presented)` | On an EVM pull pairing, the account whose signature authorises the pull. With the reference's `authorization`, it lets a reader ask the chain whether the authorization executed before any transaction is named. | These pairings have `reference` without `status`: the Lightning pairings (`mpp/charge/lightning`, `mpp/session/lightning` and `x402/exact/lnbtc/payment-hash`), `mpp/charge/nearintents`, and the seller's charge reference of `acp/checkout/undelegated`, `card/seller-reference` and `ucp/checkout/unsigned`. Some pairings carry members for their own shape of payment: | Member | Where | What it does | |---|---|---| | `channel` | channels, sessions and subscriptions | `kind` classifies a later payment as the opening, a payment within, or the close; `ref` names the channel; `boundWithin` reads H from a payment within, where one carries it; `until` gives the channel's end, where it has one. | | `buildWithin` | `mpp/session/evm`, `mpp/session/tempo`, `mpp/session/xrpl`, `x402/batch-settlement/eip155` and `x402/batch-settlement/solana` | Builds a later payment within an open channel. | | `closeRef` | `mpp/session/evm`, `mpp/session/tempo`, `mpp/session/xrpl` and `mpp/subscription/tempo` | The read keys of the channel's close. | | `landedTx`, `fetchPresented` | `mpp/charge/solana`, `mpp/charge/solana/unsponsored`, `mpp/charge/xrpl`, `mpp/charge/lcp/hedera`, `mpp/charge/tempo/split-memo/push` and `mpp/session/solana/stock`. Other pairings whose payer broadcasts, `mpp/session/evm` among them, have neither; see [Who broadcasts](https://lcp.integraledger.com/concepts/pairings.md#who-broadcasts) | The transaction a credential names, and the credential completed with that landed transaction, written under the member `FETCHED` keys, the only one `bound` and `reference` read it from; `fetchPresented` refuses a landed transaction that failed. | | `keySearch`, `keyProves` | `mpp/subscription/tempo` | The read keys of a transfer made under the subscription's access key, from the receipt that registered the key, and what the record proves for that transfer. | | `advertiseBeforeCarrier` | pairings whose carrier the seller writes after H | `advertise`'s checks and placement, without the checks on that carrier. | ## Who broadcasts `broadcaster(presented)` answers who puts what the buyer presents on its rail, and so what the seller does next. `"payer"`: the payer sent the payment before presenting it, and the seller reads the landed payment, through `fetchPresented`, `status` or `recover` where the pairing has them; where no member reads it, the seller confirms it outside the package. `"payee"`: the seller, or the facilitator or processor acting for it, sends or executes what the payer presented, such as the signed transaction `complete` returns or an authorization, and reads its settlement after. Each pairing's [API page](https://lcp.integraledger.com/reference/api.md) names the read or the execution that follows. The answer's type, `Broadcaster`, is exported from the package root and from every entry point with pairings. The members a pairing exports do not answer this. On `mpp/charge/evm/hash` and `mpp/charge/nearintents` the payer broadcasts, and neither has `landedTx` or `fetchPresented`. `broadcaster` answers only for a payment of a type and kind the pairing takes, within the shape gate its `bound` applies first, and gives any other payment the refusal `bound` gives that fault. Where a payment has a second fault that `bound` finds first, in H or the challenge, the two codes differ. A session's or batch channel's `bound` reads the opening alone, so for any other action the reader is `channel.kind`: a payment it refuses for its own content gets its refusal (a batch channel reads the payload alone, under any `accepted` option), and one a session's `channel.kind` refuses for what the challenge decides is answered. The shape gates are an MPP credential of `credentialOf`'s shape, at most 64 KiB as JSON and 16 arrays and objects deep; an x402 v2 payment whose `accepted` is an object, and whose `payload` is one too, except on `x402/batch-settlement/cloudflare`, which reads no payload; and an object, for the checkout and card pairings (on `acp/checkout/delegated`, one whose `allowance` has ACP's members). Faults `bound` finds in anything else, such as H, the challenge, an amount or a signature, do not change the answer, so `broadcaster` does not stand in for `bound`. It is pure: it takes no reader and loads no peer. The pairings whose `bound` binds nothing and applies no gate (`ack/payment-request`, `acp/checkout/undelegated`, `ucp/checkout/unsigned`, `ucp/booking/unsigned`, `card/seller-reference`) answer for whatever is presented. A pairing that reads a payload `type` or a session `action` refuses one it does not take with `bound`'s code: `mpp/credential-type` on most MPP charges, `mpp/charge/evm/transaction` and `mpp/charge/evm/hash` among them, whose `bound` gives every credential of a type they take `mpp/no-signed-place`, and `near/not-hash-credential` on `mpp/charge/nearintents`. A session takes the actions its `channel.kind` takes, and refuses any other with the code its `bound` gives a credential that is not an opening; an opening of a type its `bound` does not take gets `bound`'s code too. The EVM and Solana batch-settlement channels refuse a payload `type` their `channel.kind` does not take with `x402/not-an-opening`, and the EVM channel refuses a refund whose `amount` is not a positive decimal below 2^128 with `x402/payload-malformed`, as `channel.kind` does. Both read the payload alone, so which option `accepted` is does not change the answer. Most pairings take payments of one path, and every payment they take gets one answer. These take more than one, and answer by the payment's kind: | Pairing | `"payer"` | `"payee"` | |---|---|---| | `mpp/charge/evm/transaction`, `mpp/charge/evm/hash` | `type` `hash` | `type` `transaction` | | `mpp/charge/xrpl` | `type` `hash` | `type` `transaction` | | `mpp/charge/solana` | `type` `signature` | `type` `transaction` or `bundle` | | `mpp/session/evm` | An opening or a top-up of `type` `hash`, and a voucher carrying an opening `deposit` of that `type`. No member reads the top-up, so the seller confirms it outside the package. | An opening or a top-up of `type` `authorization` or `permit2`, and a voucher carrying an opening `deposit` of either; any other voucher; the close. | | `mpp/session/lightning` | The opening; a top-up; a bearer proof, which draws on the deposit the payer paid. | The close, whose refund the seller's node pays. | ```ts import { isRefusal } from "@integraledger/lcp"; import { evmHash } from "@integraledger/lcp/mpp"; const challenge = { id: "x", realm: "api.seller.example", method: "evm", intent: "charge", request: "e30" }; console.log(await evmHash.broadcaster({ challenge, payload: { type: "hash", hash: `0x${"55".repeat(32)}` } })); console.log(await evmHash.broadcaster({ challenge, payload: { type: "transaction", signature: "0x02" } })); const refused = await evmHash.broadcaster("not a credential"); console.log(isRefusal(refused) && refused.code); ``` ```text payer payee mpp/credential-malformed ``` ## The registry `BINDINGS` holds every pairing. `pairingOf(option)` names the x402 pairing that serves an x402 option; `pairingsOf(challenge)`, from `@integraledger/lcp/mpp`, names the MPP pairings a challenge offers. ```ts import { BINDINGS, pairingOf } from "@integraledger/lcp"; import type { PaymentRequirements } from "@integraledger/lcp/x402"; const option: PaymentRequirements = { scheme: "exact", network: "eip155:84532", amount: "10000", asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", payTo: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", maxTimeoutSeconds: 60, extra: { name: "USDC", version: "2" }, }; console.log(pairingOf(option)); console.log(pairingOf({ ...option, extra: { ...option.extra, assetTransferMethod: "permit2" } })); console.log([...new Set(BINDINGS.map((b) => b.id.split("/")[0]))].sort().join(" ")); ``` ```text x402/exact/eip155/eip3009 x402/exact/eip155/permit2 ack acp ap2 card mpp spend-permissions ucp x402 ``` ## What no pairing serves `pairingOf` returns `undefined` for an option no pairing serves, and each x402 pairing's `read` refuses a document in which it can pay no option (`x402/no-payable-option`), with the rail's optional peer or without it. Where a protocol gives the buyer nothing to sign, the pairing says so instead of inventing a place: ACK's `build` and `bound` refuse `ack/no-signed-place`. ## Next - [The buyer gate](https://lcp.integraledger.com/concepts/buyer-gate.md): what the buyer checks before `build`. - [Seller](https://lcp.integraledger.com/guides/seller.md) and [Buyer](https://lcp.integraledger.com/guides/buyer.md): the members in order, in a working flow. --- # The buyer gate > Compare the served bytes with the hash before anything is signed. Source: https://lcp.integraledger.com/concepts/buyer-gate Updated 2026-11-18. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. The **buyer gate** is the buyer-side check that compares the served bytes with H before anything is signed. Where the payment carries H, it is the one step that makes paying mean agreeing: the buyer signs only a payment bound to a record it has fetched, hashed and kept. Where the buyer's signature does not carry H, the pairing's record says so. ```mermaid sequenceDiagram participant B as Buyer participant S as Seller B->>S: request the resource S-->>B: 402 challenge carrying H and the link B->>S: fetch the link S-->>B: the ATR's exact bytes Note over B: SHA-256 over the bytes received, compared with H alt the hashes differ, or the fetch fails Note over B: decline, and sign nothing else the hashes are equal Note over B: build the payment and sign it, on most pairings with H in the field it signs B->>S: the payment, carrying H where the pairing's claims is true end ``` ## The steps 1. **Read.** The pairing's `read(doc)` gives H, the link, and the options this pairing can pay. A document without a well-formed hash and `https` link is refused before anything is fetched. 2. **Fetch.** Fetch the link and keep the bytes exactly as received. Bound the fetch: this package's shared vectors fix a limit of 1 MiB on the body, a 10-second deadline, and no redirects. Ask for the bytes as they are (`Accept-Encoding: identity`) and decline an answer in any other content coding, such as `gzip` or `br`: the hash is over the bytes served, never over bytes a decoder produced. 3. **Compare.** `hashEquals(await hash(bytes), h)`. On any difference, stop: nothing is signed. 4. **Build and sign.** The pairing's `build(choice, h)` returns what the signer signs, with H in its place. Pass the H you compared, never a value read again from the document. 5. **Finish.** `complete(signature)` gives the payment. Before sending it, check that `bound(payment)` equals the H you compared. Where the pairing's `data.coverage` is `none`, no public act the payer signs carries H, whatever `bound` returns, and the agreement payment is the proof. 6. **Keep the bytes.** The buyer's copy of the ATR is its record of what it agreed to. ## One changed byte The comparison is over bytes, not meaning. Re-serialising the same JSON, or changing one byte, gives another hash: ```ts import { hash, hashEquals } from "@integraledger/lcp"; const utf8 = new TextEncoder(); const served = utf8.encode('{"atrVersion":"1","id":"0f8fad5b-d9cb-469f-a165-70867728950e","terms":"10000 units"}'); const h = await hash(served); const reformatted = utf8.encode(JSON.stringify(JSON.parse(new TextDecoder().decode(served)), null, 1)); const edited = served.slice(); edited[served.length - 3] = 0x31; console.log(hashEquals(await hash(served), h)); console.log(hashEquals(await hash(reformatted), h)); console.log(hashEquals(await hash(edited), h)); ``` ```text true false false ``` ## The gate as a package This package gives the gate's pieces: `read`, `hash`, `hashEquals`, `build` and `bound`. The [buyer packages](https://agenticterms.integraledger.com/concepts) assemble them into one gate with a bounded fetch and named declines, for TypeScript, Python and MCP clients. They follow the rows of [`vectors/buyer.json`](https://lcp.integraledger.com/vectors/buyer.json), which this package ships. The function names in this table (`transact`, `agree`, `confirm`, `within`, `finish`) are the buyer packages' gate functions, not this package's; the ids in parentheses are the `name`s of the rows in `vectors/buyer.json` that fix each case. | Row outcome | When | |---|---| | `hash-mismatch` | The served bytes do not hash to H: one changed byte, the same JSON written another way, or an agreement resource advertising another ATR's hash. | | `signed-not-bound` | What the signer returned does not carry the H the buyer compared. | | `offer-unreadable` | The pairing's `read` refused the document, or its `build` refused the option with the buyer's inputs; the row carries the refusal code, and nothing is signed. | | `link-not-https` | The link or the agreement URL that `read` gave is not an `https` link, and it is not fetched. Each pairing's own `read` refuses a link or agreement URL of another scheme, which declines `offer-unreadable` with the refusal's code. An agreement URL refused at the agreement step, by `transact` or by `agree` called with it alone, carries this package's code for the value as its detail: `x402/link-not-https` for a URL of another scheme, `x402/legal-context-malformed` for any other value (`BA5`). | | `atr-unfetchable` | The fetch redirected, returned an error status, failed, did not answer in time, or answered in a content coding other than `identity`. | | `atr-too-large` | The body is larger than 1 MiB. The fetch is cancelled. | | `signer-failed` | The signer rejected. | | `no-payable-option` | No option is payable by the buyer's accounts. The same decline, with the detail `/input-malformed`, answers inputs the caller gave `confirm`, `agree` or `within` that are not an object, and a refund's own Solana value that is malformed (`B20`, `BA16`, `BW3`, `BW4`). Nothing is fetched or signed. | | `pairing-not-supported` | The pairing id is not one the gate implements, or `finish` is handed a chosen payment of another pairing than its binding's (`B19`), before anything is rebuilt. | | `agreement-pending` | An agreement payment for this ATR is settling, and the full payment is not signed: the gate made the agreement payment and its receipt did not arrive in time (`BA3`), or the agreement URL answered the unpaid request `202` (`BA14`), and nothing is signed. After that unpaid `202`, call again later without approval: once the agreement payment is recorded, the agreement URL answers its receipt. Never sign a second agreement payment. | | `agreement-failed` | The agreement's receipt names another ATR's hash, an agreement answer is in a content coding other than `identity`, `PAYMENT-REQUIRED` is not strict base64, padded, in the standard alphabet and with its pad bits zero (`BA13`, `BA18`, `BA19`), or the JSON text of `PAYMENT-REQUIRED` or of the receipt is led by a byte-order mark (`BA17`, `BA18`); the full payment is not signed. | | `agreement-not-offered` | The chosen pairing's payment is not a public proof of H (its `data.coverage` is `none`) and the offer names no agreement URL. The link is fetched and compared first; nothing is signed. | ## The agreement URL Where the pairing's `data.coverage` is `none`, the seller advertises an **agreement URL** (`legalContextAgreementUrl`) beside the link; the buyer gate declines such an offer without one. The buyer first pays that URL. That payment is itself a public proof of H: it carries H or, on a pairing whose single-use value is H itself or H's low bits (the EIP-3009 and Permit2 `nonce` among them), [the agreement's own value](https://lcp.integraledger.com/concepts/atr-hash.md#the-agreements-own-value), `agreementValue(h)`, so the agreement and the full payment never share a single-use value. The pairing's `build(choice, h, "agreement")` writes it, and `bound(presented, { act: "agreement", h })` checks it. The buyer pays the full payment only after the agreement's `200` receipt names the same H. Where the chosen pairing's payment is itself a public proof of H (`data.coverage` is `full`), the buyer does not pay the agreement URL. The agreement payment is a payment like any other, so the buyer's agent approves it before anything is signed: 1. **Fetch** the agreement URL's `402` and check that it advertises the same H. A `202` to this unpaid request means an agreement payment for this ATR is settling: the gate declines `agreement-pending` and signs nothing (`BA14`). 2. **Choose** its option with the main payment's rule: the options in order, the first the signer can pay whose pairing's payment is itself a public proof of H. 3. **Hand the agent** that option's amount, token (`asset`), payee (`payTo`) and network, and sign only once it approves. 4. **Pay and wait** for the `200` receipt. The exchange is bounded by the chosen option's `maxTimeoutSeconds` plus 180 seconds; `maxTimeoutSeconds` is a JSON number with an integral value, so `60.0` is `60`. After a `202` the gate sends the same payment again after `Retry-After`'s delay-seconds (RFC 9110 section 10.2.3) of 1 to 9 digits, at least 1 second, and after 2 seconds when the header is absent or in any other form, an HTTP-date included (`BA15`). The buyer vector rows `BA1` to `BA19` fix this exchange: its order, the approval and the bounds. ## What the gate checks, and what it does not The gate compares the served bytes with H before anything is signed. It never parses the ATR. - **The bytes it compared are the record.** Evaluate, and show a person, those bytes, never a second fetch of the link: `LCP §12.7` requires that "the document presented for human review is byte-identical to the document whose hash is signed". - **The ATR's text is the seller's statement.** The gate acts on nothing a party slot says. An agent that reads the slots takes their text as the seller's statement, not as instructions to it: `LCP §12.7` says free-text prose in the terms body should not "drive policy decisions directly". - **The binding slot is the seller's statement too.** The gate compares the bytes with H; it does not compare the options and request the binding slot records with the challenge it received. - **The link is the seller's choice.** `isHttpsLink` accepts loopback, private and link-local hosts, such as `127.0.0.1`, `10.0.0.1`, `169.254.169.254`, `localhost` and `[::1]`. A buyer that fetches from inside a private network refuses such destinations itself. ## Next - [Buyer](https://lcp.integraledger.com/guides/buyer.md): the gate in code, step by step. - [Vectors](https://lcp.integraledger.com/concepts/vectors.md): running the shared rows. --- # Refusals > Every refusal is a value with a code. Source: https://lcp.integraledger.com/concepts/refusals Updated 2026-11-18. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. Failures are values. A function in this package whose type carries a refusal returns its result, or a **refusal**: a plain object that names what is wrong with its input. A `status` answers a state and its reason instead ([Readers](https://lcp.integraledger.com/concepts/refusals.md#readers)), and the writers that only encode a value you supply throw ([What throws](https://lcp.integraledger.com/concepts/refusals.md#what-throws)). ```ts no-check type Refusal = { refused: true; code: string }; ``` A code is `/`, such as `core/slot-name`, `x402/link-not-https` or `svm/memo-not-lcp`. The namespace is the entry point or rail that refused. The same reason means the same thing on every surface: `link-not-https` is always a link that is not `https` (any such link given to `advertise` or `place`, and a link of another scheme that a `read` finds, except card's, ACK's and AP2's, which give `legal-context-malformed` to every link that is not `https`), and `legal-context-malformed` is always a hash, link or agreement URL that does not read. The [refusal code reference](https://lcp.integraledger.com/reference/refusals.md) lists every code with its meaning. ## Checking a result `isRefusal(result)` is how a caller tells a refusal from a result: it is true only for a refusal a copy of this package made, and false for every result, the hashes `bound` returns included. Every installed copy of the package recognises the refusals of every other, as when two installs serve one process. Test it before using a result: ```ts import { assemble, isRefusal, newAtrId } from "@integraledger/lcp"; const result = await assemble(newAtrId(), ["bind", {}], [["id", new TextEncoder().encode("{}")]]); if (isRefusal(result)) { console.log(result.code); } else { console.log(result.atrHash); } ``` ```text core/slot-reserved ``` ## Where a refusal comes from Only the package makes refusals. `isRefusal`, which the package's own entry points use as well, recognises a refusal by a mark the package sets on it, not by its members: a non-enumerable own property keyed by the registered symbol `Symbol.for("@integraledger/lcp/refusal")`. JSON carries no symbol, and a spread or a `structuredClone` copy holds no non-enumerable property, so a value read from JSON or copied is not a refusal, and a value you pass in is never returned to you as a refusal, whatever members it holds. `JSON.stringify` and `canonicalJson` write a refusal as its two members. A presented payment or credential that the package would otherwise hand back to you unchanged is refused as malformed when it carries a `refused` member: `mpp/credential-malformed` for an MPP credential, `x402/payload-malformed` for an x402 EIP-3009 payment and `casper/payload-malformed` for a Casper payment. `unplaced`, which gives back the option or challenge you pass or a copy of it without the pairing's carrier, and each placement, which gives back a copy of the seller's document with the carrier placed (`advertise` and `advertiseBeforeCarrier` on the x402, MPP, ACP, AP2 and UCP pairings, and MPP's and A2A's `place`), refuse a value that carries a `refused` member before they remove or place anything: with `x402/option-malformed` on x402 (for a document, when it or an option in its `accepts` carries one), with `mpp/challenge-malformed` on MPP (for a list of challenges, when any of them carries one), and elsewhere with the malformed code of what they are given: the pairing's `option-malformed` code for an option given to `unplaced` on the ACK, ACP, AP2, card and UCP pairings, and `acp/session-malformed`, `ap2/jws-malformed`, `ucp/checkout-malformed` or `a2a/legal-context-malformed` for the session, checkout payload, checkout or task a placement is given. Every other entry point reads a presented value only for the members its pairing defines, and returns either a value it built or its own refusal. ## What throws A writer encodes a value you supply, and its type carries no refusal: it throws a `TypeError` on an argument outside its type. In the core, `hash` rejects with one when its argument is not a `Uint8Array`: a `Buffer` or a `Uint8Array` from another realm is hashed, and a string, an array, an `ArrayBuffer`, another typed array or a Proxy is not. `toLcpString`, `toLegalContext` and `toRawBytes` throw when the hash is not 32 bytes, and `toLegalContext` also when the link is not an `https` URL. Their `from…` counterparts return `null` instead of throwing. `agreementValue`, which is asynchronous, rejects when the hash is not 32 bytes. The rails' writers throw the same way (`x402InvoiceId` and `svmDigest`, which are asynchronous, reject): - on a hash that is not 32 bytes: `ccdMemo` and `pltMemo`, and `mppInvoiceId` and `x402InvoiceId`; - on a Hedera value outside its type: `txIdText` and `txIdMirror` (an id that is not an account `shard.realm.num`, a non-negative bigint `seconds` and `nanos` from 0 to 999,999,999), `hederaChannelId` (an address that is not `0x` and 40 hex digits, a salt that is not a 32-byte hash, a chain id other than 295 and 296) and `hederaVoucher` (the same for the channel, and a `cumulative` that is not a bigint that fits a uint128); - on a field of the wrong type: `encodeTronRaw`, `encodeProfileCall` (a call `decodeProfileCall` would not give back), `openInstructionData` and `channelVoucherMessage`, and `sessionProof` on a null or missing argument or a `channelId`, `payer` or `challengeId` that is not a well-formed string, so that it never returns a message you did not write; - on bytes that are not a `Uint8Array`: `extrinsicHash`, `stacksTxid`, and `svmDigest` on a transaction whose message is not one; - on a network other than `starknet:SN_MAIN` and `starknet:SN_SEPOLIA`: `chainIdFelt`. Every other function answers a caller's input with a value, never a throw: a refusal, a `status` answer, `false` or `{ complete: false }` from a read, or, for `unplaced`, its argument itself when that is not an option. ## Readers The functions that read a rail (`status`, `recover`, `fetchPresented`) take a reader you supply, so the network calls are yours. `status` refuses nothing: it answers `settled`, `pending`, `failed` or `unreadable`, each with a reason, as the [read-status profile](https://lcp.integraledger.com/profiles/read-status.md) states them. A reader that fails or times out is never a failed payment: a read that did not complete answers `unreadable` with the reason `transport`, and a later read can settle it. A reader that declares a network other than the one the reference names is never a failed payment either, and nothing is read through it: `status` answers `unreadable` with the reason `chain-mismatch` on every read, so no later read settles it, and `recover` refuses `/wrong-reader`. A ref or reader that is not an object is answered with nothing read: `status` answers `unreadable`, and `recover` refuses with the code it gives a reader for another network. So does a `recover` given a ref whose transaction id is not in its rail's form, which can name no transaction. Check `reader.network` against the reference's network before you poll, and give every polling loop a deadline of its own. ## Reads to repeat A refusal from a read is a verdict or a read to repeat. `readToRepeat(code)` is true for a read to repeat: the answer rests on a read of the rail that may answer differently later, with nothing for you to change, so ask again later. The payment may already have moved, so do not ask the buyer to pay again. These are each reader's `/unreadable` (the reader failed, or answered out of its documented form) and `/not-found` (no landed transaction for the reference yet), and the codes of a transaction that is not final yet: `casper/not-executed`, `ccd/not-finalized`, `xrpl/not-validated`, `evm/not-final` (a revert, or a receipt without what the read looks for, above the reader's `finalized` mark), `polkadot/not-final` (an extrinsic not dispatched as the payment, in a block above the finalized height), `stacks/not-final` (a failure in a block fewer than two tenures below the tip), `starknet/not-final` (a revert, or no single matching transfer, in a pre-confirmed block), `svm/not-final` (a transaction the read at Solana's `confirmed` holds and the read at `finalized` does not, with an error or none) and `tempo/not-final` (as `evm/not-final`, on Tempo). The [refusal code reference](https://lcp.integraledger.com/reference/refusals.md) marks each of them. Every other code is false. A verdict, such as `evm/reverted`, gives the same answer on every read. A call you must change before it can succeed gives the same answer too, so it is not a read to repeat: `/wrong-reader` (a reader for another network, or a ref the rail cannot read), `/read-first` (`bound` or `reference` on a push credential before `fetchPresented` has read it), a missing peer dependency, and malformed input. A code the package does not return is false, whatever its reason. ```ts import { readToRepeat } from "@integraledger/lcp"; const codes = ["xrpl/not-validated", "tempo/not-final", "evm/unreadable", "evm/reverted", "evm/wrong-reader", "svm/read-first", "server/unreadable"]; for (const code of codes) console.log(code, readToRepeat(code)); ``` ```text xrpl/not-validated true tempo/not-final true evm/unreadable true evm/reverted false evm/wrong-reader false svm/read-first false server/unreadable false ``` ## Next - [Refusal codes](https://lcp.integraledger.com/reference/refusals.md): every code, with its meaning. --- # Vectors > The shared test cases that fix the rules byte for byte across languages. Source: https://lcp.integraledger.com/concepts/vectors Updated 2026-11-18. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. **Vectors** are the shared test cases that fix the rules byte for byte across languages. The package ships them in `vectors/`, one JSON file per entry point or pairing. Any implementation of the Legal Context Protocol, in any language, that passes them assembles the same bytes, computes the same hashes, and places and reads H in the same fields as this package. Every expected byte, hash and signature in a vector file comes from outside this package: a specification's published example, a standard's test value such as SHA-256 of `"abc"` from FIPS 180-2, a transaction read from a live network, or an independent tool (Python's `json` and `hashlib`, `sha256sum`, `openssl`, viem, eth-account, a rail's own SDK). Refusal codes are this package's own, not a specification's; a file's `agreedRefusals` rows hold the codes for checks its specification leaves to the implementation. Each file's `about` names its sources. ## What they fix | Area | Files | What the rows fix | |---|---|---| | The core | `core-vectors.json` | The ATR's exact bytes and hash for given inputs, the https-link rule, the JSON nesting cap, and the `assemble` refusals its rows name. | | The buyer gate | `buyer.json` | What a buyer does with an advertised challenge: when it signs, and each decline. | | Each pairing | `x402-*.json`, `mpp-*.json`, `acp-checkout.json`, `ucp.json`, `ucp-checkout-agent-signed.json`, `ap2-checkout-mandate.json`, `ap2-checkout-mandate-x402.json`, `ack-payment-request.json`, `card.json`, `spend-permissions-eip155.json` | The placed challenge, what the payer signs with H in it, H read back from the payment, and the settlement read. | | Who broadcasts | `broadcaster.json` | Each pairing's `broadcaster` answer: one for every payment it takes, or by the kind of payment, with a credential of each kind; and payments of a type, kind or shape the pairing does not take, each refused with `bound`'s code. | | Shared readers | `sd-jwt.json`, `decoder-caps.json`, `discovery.json`, `a2a-legal-context.json` | The SD-JWT reader, the decoders' limits, the discovery document and the A2A extension. | | Shared reads and encodings | `read-status.json`, `charge-reference.json`, `legal-context-return.json`, `base64-platform.json`, `stellar-position.json`, `svm-read.json` | The cases common to every pairing's read (the [read-status profile](https://lcp.integraledger.com/profiles/read-status.md)), the seller's charge reference, the return after an agreement, base64 on every platform, the Stellar position, and the Solana read. | The [vector files reference](https://lcp.integraledger.com/reference/vectors.md) lists every file with its `about`. ## Running them The files ship inside the package, beside `dist/`. This example runs the core rows of `core-vectors.json` through `assemble` and checks each expected hash: ```ts import { readFile } from "node:fs/promises"; import { assemble, isRefusal, type Json } from "@integraledger/lcp"; const url = new URL("../vectors/core-vectors.json", import.meta.resolve("@integraledger/lcp")); const core = JSON.parse(await readFile(url, "utf8")) as { vectors: { name: string; id?: string; binding?: [string, Json]; content?: [string, string][]; expectHash: string }[]; }; for (const v of core.vectors) { if (v.id === undefined || v.binding === undefined || v.content === undefined) continue; const content = v.content.map(([slot, hex]) => [slot, Uint8Array.from(Buffer.from(hex, "hex"))] as const); const atr = await assemble(v.id, v.binding, content); console.log(v.name, !isRefusal(atr) && atr.atrHash === v.expectHash); } ``` ```text V1 true V2 true V3 true ``` The package's own test suite runs every file. A `buyer` row, in `buyer.json` or in another file, describes a buyer gate, which this package does not contain: the suite runs the parts of those rows the package implements (hashing, `read`, `bound` and the builds the rows name). The [buyer packages](https://agenticterms.integraledger.com/reference/vectors) run those rows whole, every row of `buyer.json` and the `buyer` rows of every other file, from TypeScript and from Python, at the version of this package they pin. ## Plants A row marked `plant` is a deliberate wrong input with a known outcome: bytes one changed byte away from the ATR, a receipt whose matching log comes from another contract, an agreement resource advertising another ATR's hash. A check that accepts a plant is broken, whatever else it passes. --- # The settler > The x402 facilitator role, and the settler the protocol ships for the x402 pairings lcp implements. Source: https://lcp.integraledger.com/concepts/settler Updated 2026-11-20. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. In x402, a **facilitator** is the role that verifies and settles. A resource server sends it the buyer's payment and the requirements that payment answers. `POST /verify` says whether the payment is valid, `POST /settle` submits it to its network and answers with the transaction, and `GET /supported` lists the kinds of payment it serves. The seller chooses its facilitator. This page is for a seller choosing one, and for the operator of the settler: at the end you know where the facilitator sits beside the resource server, and what the settler declares and records. ## Where it sits The resource server and the facilitator do different jobs, in this order: 1. **The resource server checks H.** `bound(payment)` reads H from what the buyer presented, and the resource server accepts the payment only where that H is the one it issued for this request and has not accepted before ([Seller: check the payment](https://lcp.integraledger.com/guides/seller.md#4-check-the-payment)). Those two facts are its own records, and its refusals come here, before money moves. 2. **The facilitator verifies and settles.** `/verify` says the payment is valid for its requirements; `/settle` submits it and names the transaction. 3. **The resource server reads the settlement.** The facilitator's `transaction` is the payment's reference on chain, and `status` reads it through a reader the resource server supplies ([Seller: read the settlement](https://lcp.integraledger.com/guides/seller.md#5-read-the-settlement)). ```mermaid sequenceDiagram participant B as Buyer participant R as Resource server participant S as Settler participant N as Node B->>R: the payment, carrying H Note over R: bound(payment) equals the H it issued R->>S: POST /verify, then POST /settle S->>N: submit what the payer signed S-->>R: success, transaction, payer Note over R: status reads the transaction ``` ## The settler `@integraledger/profile-facilitator`, in this repository's [`settler/`](https://github.com/IntegraLedger/integra-protocol/tree/main/settler) folder, is a facilitator for the x402 pairings `@integraledger/lcp` implements, which holds each payment to its pairing's LCP profile (hence its name), on one HTTP surface: `GET /supported`, `POST /verify` and `POST /settle`. It runs x402's own facilitator class, `x402Facilitator` of `@x402/core` 2.31.0, with one registration for each scheme on each network it is configured with. Behind each registration is a **module**: x402's published facilitator class for that chain, registered unchanged, or the settler's own facilitator where x402 publishes no class. Around the class it adds three things: - **lcp's checks of the pairing**, made from the payment and its requirements alone before the class is asked: the payment carries H in its profile's form, and its form is one the kind declares. - **The record**: one row per payment in Postgres, so that one payment is submitted once and answered success once. - **lcp's read of the chain**, which decides whether a payment the class did not answer success for is final. It checks the amount, asset and payee against the requirements because x402 requires that of a facilitator, and carries no business or legal logic beyond that. It does not know which H the resource server issued. ## What it declares There is no list of the settler's kinds: a resource server reads them from `/supported`. Each kind's `extra` carries, with the class's own members: - `extra.pairings`: the pairing ids the kind submits, since a scheme on one network can hold several forms. - `extra.key`: what the module's key signs. `none`: the module holds no key and submits what the payer signed, and the payer pays the fee. `relayer`: the key sends the transaction and pays its network fee. `fee-payer`: the key co-signs the payer's transaction as the account that pays its fee. The key is always the seller's, given to the module as the signer object its class takes. - `extra.acceptsZero`: the pairings the kind settles at an amount of zero, `[]` where none does, which a seller choosing a zero agreement amount needs to know. - `extra.feeBudget`: present, and `true`, where the operator capped the fees its keys pay on the network, so that the settler may refuse every payment there for a period. A deployment with a keyed module does not start without a credential, and every call must then present it: the resource server names the payee and the amount, and an open settler would pay fees for payments between other parties. ## The record The settler keys each payment by its **instrument**, the single-use value its signer signed as the pairing's profile names it: an authorization nonce, a sequence number, an account nonce, or a transaction id that the signed content alone fixes; where the pairing's single-use value is not shown (a batch settlement, an `upto` claim), the digest of the signed payment. It is never the single-use value alone, which two payers can share, and never a hash that a copy signed again would change, so an agreement and a payment of one payer under one H are two instruments. A payment is claimed by one conditional insert, so of two settles of one payment only one submits, and a success is answered once, to the settle whose write stored it. A row is final once its answer can never change: a success, a failed result that consumed the single-use value, a value another act consumed, a validity that passed with the value unused, or a payment that landed by another route. A repeated `/settle` of a final row answers `invalid_transaction_state` naming the transaction, never a second success, as x402's `exact` family requires. Where the chain has not yet shown a final answer, `/settle` answers `settlement_pending` naming the transaction, and a repeat reads the chain again. [Run the settler](https://lcp.integraledger.com/guides/settler.md) starts it and configures each module, and the [settler reference](https://lcp.integraledger.com/reference/settler.md) gives its HTTP API, its reasons and its storage.