# Integra Protocol: Guides > The 9 pages of the section Guides of https://lcp.integraledger.com/llms.txt, in its order. They document @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. # Seller > Assemble the ATR, advertise its hash, check the payment, and read the settlement. Source: https://lcp.integraledger.com/guides/seller Updated 2026-11-19. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. The **seller** is the party serving the resource. Its side of the binding has four steps: assemble the ATR for this request, advertise H in the challenge, read H back from the payment it receives, and read the settlement from the rail. This guide walks them on x402 with `x402/exact/eip155/eip3009`. Every pairing has the same [members](https://lcp.integraledger.com/concepts/pairings.md#the-members), so the shape is the same on every surface; eight have no `build`, because the payer's own client builds their payment ([On other surfaces](https://lcp.integraledger.com/guides/seller.md#on-other-surfaces) names them). At the end you have a program that runs the seller's whole side, and the exchanges an agreement-first sale adds. ```mermaid sequenceDiagram participant B as Buyer participant S as Seller participant St as Seller's storage participant F as Facilitator B->>S: GET /v1/quote Note over S: requestCommitment, tie, assemble S->>St: write the ATR's bytes at the link Note over S: advertise H and the link in the 402 S-->>B: 402 PaymentRequired B->>S: the payment, carrying H Note over S: bound(payment) equals the H it issued S->>F: verify and settle F-->>S: the settlement transaction Note over S: reference, then status through a reader ``` The **facilitator** is the x402 role that verifies and settles. It is the seller's to choose; this package does not call it. This repository's [settler](https://lcp.integraledger.com/concepts/settler.md) is one, for most of the x402 pairings this package implements; [What it does not serve](https://lcp.integraledger.com/guides/settler.md#what-it-does-not-serve) lists the others. ## 1. Assemble the ATR for this request The ATR's binding slot ties the record to one payment. On x402, `tie(accepts, request)` records every option the challenge offers, exactly as issued, and the commitment to the request it answers: the method, the path, the query and SHA-256 over the body exactly as received. The party slots carry whatever the parties agreed, as bytes. ## 2. Store the bytes and link them Write the ATR's bytes to your own storage before the challenge goes out, and serve them unchanged at an `https` link. If the write fails, send no challenge: a buyer that cannot fetch the record declines. ### Serving the link The buyer gates decline the link unless it answers `200` with no redirect, in the identity coding (no `Content-Encoding`, or `identity`), with at most 1 MiB, within 10 seconds ([`vectors/buyer.json`](https://lcp.integraledger.com/vectors/buyer.json) rows `B11` to `B14` and `BE1`). Make the link unguessable: H is in the challenge, and on most pairings in the payment, so build the link from a random token, not from H. Let it expire after a short period, minutes (`LCP §12.4`), once the buyer has had time to fetch the bytes (`LCP §6.1`). The binding slot records the request's path and query, and the link serves those bytes to whoever fetches it, so keep secrets out of the query. ## 3. Advertise H `advertise(doc, h, link, offer)` returns a copy of the challenge with `extensions.legalContext.info` set to `{"type":"sha256","value":H,"legalContextUrl":link}`, beside its `schema`, and leaves every other extension and every option as they were. On pairings that carry H in the option itself, such as `x402/exact/solana` (`extra.memo`), it also places H there. A challenge, or an option in its `accepts`, that carries a `refused` member is refused as `x402/option-malformed` before anything is placed ([Refusals](https://lcp.integraledger.com/concepts/refusals.md#where-a-refusal-comes-from)). Send the result as `encodeHeader(advertised)` in the `PAYMENT-REQUIRED` header of the `402` ([The headers](https://lcp.integraledger.com/guides/x402.md#the-headers)). ## 4. Check the payment Read the payment from the retried request's `PAYMENT-SIGNATURE` header with `decodePaymentSignature(header)`. `bound(payment)` reads H from what the buyer presented: here, the EIP-3009 authorization's `nonce`. Match it with `hashEquals` against the H you issued for this request. The token contract verifies the signature when it executes the transfer; `bound` does not. Refuse a payment whose H you did not issue for this request, and one whose H you have already accepted. Those two facts are your records, not this package's. ## 5. Read the settlement `reference(payment, option)` gives the keys for finding this payment on chain, with the payee of `option`, the option the payment answers: the network, the token (`asset`), the payer, `validBefore`, H (`h`) and `presented`, the authorization's members as presented. After the facilitator settles, add the transaction its settle answer names as `transaction`: `status` reads it beside its own search, and never needs it. `status(ref, reader, query)` then reads the act `query.act` names, `"payment"` here, through a reader you supply, at the finality `query.finality` asks for. Ask for `"finalized"`: a block above that mark can be replaced. `recover({ network, tx, option }, reader)` reads H back from the transaction alone. `status` answers `settled`, `pending`, `failed` or `unreadable`, each with one reason from a closed list ([the x402 guide](https://lcp.integraledger.com/guides/x402.md#reading-the-payment) gives it). It settles on a transaction that carries H, was signed by the payment's payer and pays the option's payee, read at the finality asked for or above it; below it, the answer is pending `below-mark`. It never compares the amount: `presented` on a settled answer says whether the landed authorization is the one presented. A reader call that rejects, or a reader that declares another network, makes the answer `unreadable`, never `failed`. Each rail's marks are in [Reading settlement](https://lcp.integraledger.com/guides/rails.md#reading-settlement). Before any transaction is named, `status` reads whether the authorization has been used: at the final mark, and, through a reader that has `block`, at the latest head. It answers pending `instrument-live` while the authorization is unused at both and still valid. `authorizer(payment)` gives the account whose signature authorises the transfer, and `authorizationUsed({ network, authorization }, authorizer, block, reader)` asks the token whether that authorization had executed by a given block, with `authorization` built from the reference as the program below builds it. The authorization cannot execute in a block whose timestamp is at or after its `validBefore`, so once a final block is past that time, an unused authorization never moves money. ## The whole flow This program runs every step above. A `Map` stands in for the seller's storage, a random key for the buyer's signer, and a reader built from one receipt for the chain. No network is used. ```ts import { assemble, hashEquals, isRefusal, newAtrId } from "@integraledger/lcp"; import { AUTHORIZATION_USED_TOPIC, TRANSFER_TOPIC, authorizationUsed, type EvmReader, type Hex, } from "@integraledger/lcp/evm"; import { decodePaymentRequired, decodePaymentSignature, encodeHeader, exactEip3009, requestCommitment, tie, type PaymentRequired, type PaymentRequirements, } from "@integraledger/lcp/x402"; import type { TypedDataDefinition } from "viem"; import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; const option: PaymentRequirements = { scheme: "exact", network: "eip155:84532", amount: "10000", asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", payTo: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", maxTimeoutSeconds: 60, extra: { name: "USDC", version: "2" }, }; const challenge: PaymentRequired = { x402Version: 2, resource: { url: "https://api.seller.example/v1/quote" }, accepts: [option], }; // 1. Assemble the ATR for this request. const request = await requestCommitment({ method: "GET", target: "/v1/quote", body: new Uint8Array() }); if (isRefusal(request)) throw new Error(request.code); const terms = new TextEncoder().encode('{"text":"One quote for 10000 base units of USDC."}'); const atr = await assemble(newAtrId(), tie(challenge.accepts, request), [["terms", terms]]); if (isRefusal(atr)) throw new Error(atr.code); // 2. Store the bytes and link them. const link = `https://atr.seller.example/${crypto.randomUUID()}`; const storage = new Map([[link, atr.bytes]]); // 3. Advertise H. const advertised = exactEip3009.advertise(challenge, atr.atrHash, link, option); if (isRefusal(advertised)) throw new Error(advertised.code); console.log("advertised:", JSON.stringify(advertised.extensions?.["legalContext"]?.info) === JSON.stringify({ type: "sha256", value: atr.atrHash, legalContextUrl: link, })); const paymentRequired = encodeHeader(advertised); // the 402's PAYMENT-REQUIRED header if (isRefusal(paymentRequired)) throw new Error(paymentRequired.code); // The buyer's side, in brief: see the buyer guide. const required = decodePaymentRequired(paymentRequired); if (isRefusal(required)) throw new Error(required.code); const payer = privateKeyToAccount(generatePrivateKey()); const unsigned = await exactEip3009.build({ required, accepted: option, from: payer.address, now: 1790000000 }, atr.atrHash); if (isRefusal(unsigned)) throw new Error(unsigned.code); const signed = unsigned.complete(await payer.signTypedData(unsigned.typedData as TypedDataDefinition)); if (isRefusal(signed)) throw new Error(signed.code); const paymentSignature = encodeHeader(signed); // the retried request's PAYMENT-SIGNATURE header if (isRefusal(paymentSignature)) throw new Error(paymentSignature.code); // 4. Check the payment. const payment = decodePaymentSignature(paymentSignature); if (isRefusal(payment)) throw new Error(payment.code); const h = await exactEip3009.bound(payment); if (typeof h !== "string") throw new Error(h.code); console.log("bound to the issued H:", hashEquals(h, atr.atrHash), storage.has(link)); // 5. Read the settlement. The facilitator's settle answer names the transaction. const ref = await exactEip3009.reference(payment, option); if (isRefusal(ref)) throw new Error(ref.code); const transaction: Hex = `0x${"11".repeat(32)}`; const word = (hex: string): Hex => `0x${hex.replace(/^0x/, "").toLowerCase().padStart(64, "0")}`; const reader: EvmReader = { network: "eip155:84532", receipt: async () => ({ status: 1, blockNumber: 100n, logs: [ { address: option.asset as Hex, topics: [AUTHORIZATION_USED_TOPIC, word(payer.address), h], data: "0x" }, { address: option.asset as Hex, topics: [TRANSFER_TOPIC, word(payer.address), word(option.payTo)], data: word(BigInt(option.amount).toString(16)), }, ], }), blockNumber: async (tag) => (tag === "finalized" ? 100n : 105n), transaction: async () => null, // The token's authorizationState(authorizer, nonce): true once the authorization is used. call: async () => word("1"), }; // Ask about the act "payment" at the final mark; the answer names the reason where it is not settled. const status = await exactEip3009.status({ ...ref, transaction }, reader, { act: "payment", finality: "finalized" }); console.log("status:", status.state, status.state === "settled" ? status.finality : status.reason); const authorizer = await exactEip3009.authorizer(payment); if (typeof authorizer !== "string") throw new Error(authorizer.code); // The authorization as the token records its use, from the reference: the token, the nonce the payer signed (H), and // its validBefore. const authorization = { scheme: "eip3009", at: ref.asset, nonce: ref.h, deadline: ref.validBefore, asset: ref.asset } as const; console.log("authorization used by block 100:", await authorizationUsed({ network: ref.network, authorization }, authorizer, 100n, reader)); const recovered = await exactEip3009.recover({ network: ref.network, tx: transaction, option }, reader); console.log("recovered from the chain alone:", typeof recovered === "string" && hashEquals(recovered, atr.atrHash)); ``` ```text advertised: true bound to the issued H: true true status: settled finalized authorization used by block 100: true recovered from the chain alone: true ``` ## The agreement URL Where the chosen pairing's `data.coverage` is `none`, the payment is not a public proof of H, and the buyer gates require an agreement URL: pass it to `advertise` as `agreementUrl`, and `read` returns it as `agreement`. The buyer gates decline an offer that names none (`agreement-not-offered`). The buyer pays that URL first, with a payment that is itself a public proof of H, and makes the full payment only after the URL's receipt. Build the agreement URL from a random token too, not from H, as [Serving the link](https://lcp.integraledger.com/guides/seller.md#serving-the-link) says of the link: unpaid, it answers with a challenge that advertises the link. [`vectors/buyer.json`](https://lcp.integraledger.com/vectors/buyer.json) fixes the exchange in `fixed.agreement` and the `BA` rows: - **Unpaid**, the URL answers `402` with `PAYMENT-REQUIRED`: the base64 of an x402 challenge, pad characters included and pad bits zero (RFC 4648 §3.5), as a standard encoder writes it, advertising the same H and link. The buyer gates decline a challenge that advertises another H (`BA2`), a header without its pad characters (`BA13`) and a header with a pad bit set (`BA19`). - **Settling**, a paid request answers `202` with `Retry-After`, and the buyer sends the same signed payment again, until the agreement option's `maxTimeoutSeconds` plus 180 seconds have passed (`BA1`, `BA3`). The buyer gates decline an unpaid request answered `202` as `agreement-pending`, and sign nothing (`BA14`). - **Recorded**, a paid request answers `200` with the receipt `{"atrHash": H, "agreed": true, "network": …, "transaction": …}`. The buyer gates require all four members: `atrHash` naming the same H (`BA4`), `agreed` true, and `network` and `transaction` strings. Answer in the identity coding: the buyer asks with `Accept-Encoding: identity` and declines any other `Content-Encoding` (`BE2`). [The agreement URL](https://lcp.integraledger.com/concepts/buyer-gate.md#the-agreement-url) gives the buyer's side. ## Serving the return Once the agreement is recorded, the buyer's agent repeats its request for the charge. The LCP profile [`legal-context-return`](https://lcp.integraledger.com/profiles/legal-context-return.md) states the rules; the seller's part is this: 1. **The first response** carries H, the link and the agreement URL, and no charge option the payer could pay before the agreement. 2. **Each agreement option names the charges it serves**, each `/`: the option at index `i` of the charge options the ATR's binding slot of that name holds (`accepts` of `x402`, `challenges` of `mpp`, `paymentOptions` of `ack`, `options` of `acp`, `ap2`, `card` and `ucp`), so a buyer pays an agreement that serves the charge it means to pay. A card sale whose agreement is an x402 option names its card options `card/`. On x402 the member is `extra.legalContextServes` (`LEGAL_CONTEXT_SERVES`), an array of those names; on MPP it is the `opaque` member of that name, the names joined by one space. It is part of the option as issued, so write it before you record the option's digest. `servesOf(option, atr?)` reads it, and refuses a malformed one `return/serves-malformed`, and, given the ATR's bytes, one that names a slot the ATR does not bind or an index past that slot's options. 3. **A return value**, where the charge is paid by a bearer value such as a Lightning preimage: draw 32 random bytes for the sale, keep them in your own record, never in the ATR, and send them with H in a `Legal-Context` response header, which `toLegalContextHeader(h, returnValue)` writes. 4. **The check.** On the returning request, `checkLegalContextReturn(value, record)` takes the `Legal-Context` request header's value and your own record for the request, `{ h, returnValue? }`. Serve the charge only where it answers `true`. It refuses a value that does not parse (`return/header-malformed`), another H (`return/not-this-sale`), and a return value that differs from the record's, one given where the record holds none included (`return/value-mismatch`). Over MCP, the same value arrives in the tool call's `params._meta` under `LEGAL_CONTEXT_META`, `com.integraledger.lcp/legal-context`. ```ts import { checkLegalContextReturn, hash, isRefusal, LEGAL_CONTEXT_HEADER, RETURN_VALUE_BYTES, servesOf, toLegalContextHeader, } from "@integraledger/lcp"; const h = await hash(new TextEncoder().encode("the ATR's bytes")); // The agreement option serves the charge at index 0 of the ATR's x402 slot. const agreementOption = { scheme: "exact", network: "eip155:84532", amount: "1", asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", payTo: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", maxTimeoutSeconds: 60, extra: { name: "USDC", version: "2", legalContextServes: ["x402/0"] }, }; console.log(servesOf(agreementOption)); // The first response: a return value drawn for this sale, kept in the seller's record, sent with H. const record = { h, returnValue: crypto.getRandomValues(new Uint8Array(RETURN_VALUE_BYTES)) }; const sent = toLegalContextHeader(record.h, record.returnValue); if (isRefusal(sent)) throw new Error(sent.code); // The return: the buyer's agent repeats the request with the same value. const request = new Request("https://api.seller.example/v1/quote", { headers: { [LEGAL_CONTEXT_HEADER]: sent } }); console.log(checkLegalContextReturn(request.headers.get(LEGAL_CONTEXT_HEADER), record)); console.log(checkLegalContextReturn(toLegalContextHeader(h), record)); ``` ```text [ 'x402/0' ] true { refused: true, code: 'return/value-mismatch' } ``` ## What the seller keeps Keep H, the link and the reference for each payment, the return value of a sale that has one, and the ATR's bytes in your storage after the link expires; the buyer keeps its own copy. ## What this package does not do It holds no key and signs nothing. It does not call the facilitator, move funds, or decide whether to serve a request. It never judges amount, payee, asset, timing or payer, and never reads the parties' content in the ATR. Beside the binding, it checks only the form the rail or the scheme requires and the bounds within which it reads its input. ## On other surfaces The members are the same everywhere, 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 calling it on a pairing taken from `BINDINGS`. What `tie`, `advertise` and `bound` handle differs: - [x402](https://lcp.integraledger.com/guides/x402.md): the `legalContext` extension, and every x402 pairing. - [MPP](https://lcp.integraledger.com/guides/mpp.md): H as the challenge id. - [Agentic checkouts](https://lcp.integraledger.com/guides/checkouts.md): ACP, UCP, AP2, ACK, card networks and A2A. - [Channels, sessions and subscriptions](https://lcp.integraledger.com/guides/sessions.md): one ATR for a whole channel. --- # Buyer > Read the challenge, compare the served bytes with H, build and sign, and finish. Source: https://lcp.integraledger.com/guides/buyer Updated 2026-11-19. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. The buyer's side of the binding is the [buyer gate](https://lcp.integraledger.com/concepts/buyer-gate.md): compare, then build and sign, then finish. This guide writes it with this package's pieces on x402 with `x402/exact/eip155/eip3009`; at the end you have a program that reads a seller's `402`, compares the served bytes with H, and signs a payment that carries it. For a ready-made gate with the fetch bounds and declines already in place, use the [buyer gate packages](https://agenticterms.integraledger.com/guides/pay-with-the-gate). ## 1. Compare Read the challenge from the `402` answer's `PAYMENT-REQUIRED` header with `decodePaymentRequired(header)`. Then `read(doc)` gives H, the link, and the options the pairing can pay. Fetch the link with bounds, keep the bytes exactly as received, and compare their hash with H. On any failure, stop before anything is signed. The fetch below is the one the shared vectors fix: one `GET` asking for the identity coding (`Accept-Encoding: identity`), no redirects, a 10-second deadline over headers and body, at most 1 MiB, counted as the body streams, and an answer in any other content coding declined. It asks with `redirect: "manual"` and reads a `3xx` answer, or the `opaqueredirect` answer with status `0` that browsers give, as a failure. Cloudflare Workers refuse `redirect: "error"` with a `TypeError`, and under `"manual"` a Worker's `fetch` answers a redirect with the `3xx` itself (measured on Cloudflare's runtime with wrangler 4.141.0). In a browser, `Accept-Encoding` is a forbidden request header and a cross-origin answer's `Content-Encoding` is hidden unless the seller exposes it, so the coding check cannot be made there. ## 2. Build and sign `build(choice, h)` returns what the signer signs with H in its place. On `x402/exact/eip155/eip3009` that is EIP-712 typed data for `TransferWithAuthorization` whose `nonce` is H, valid until `now` plus the option's `maxTimeoutSeconds`. Your signer signs it; this package never holds a key. Pass the H you compared. Never read H from the document again between the comparison and `build`. ## 3. Finish `complete(signature)` gives the x402 payment, echoing the challenge's `resource` and `extensions` unchanged. Before sending it, read H back with `bound(payment)` and check that it equals the H you compared: the signer signed what you asked it to sign. ## The whole flow The seller's challenge below was advertised for an ATR the buyer can fetch. A stand-in `fetch` serves the bytes, so no network is used. ```ts import { hash, hashEquals, isRefusal } from "@integraledger/lcp"; import { decodePaymentRequired, encodeHeader, exactEip3009, type PaymentRequired } from "@integraledger/lcp/x402"; import type { TypedDataDefinition } from "viem"; import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; const MAX_ATR_BYTES = 1_048_576; /** * One GET asking for the identity coding, no redirects, a 10-second deadline, and at most 1 MiB. The bytes as * received, or why not. */ async function fetchAtr(link: string, get: typeof fetch = fetch): Promise { const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), 10_000); try { const response = await get(link, { redirect: "manual", signal: controller.signal, headers: { "accept-encoding": "identity" }, }); const redirected = response.type === "opaqueredirect" || (response.status >= 300 && response.status <= 399); if (redirected || response.status !== 200 || response.body === null) return "atr-unfetchable"; const coding = (response.headers.get("content-encoding") ?? "").trim().toLowerCase(); if (coding !== "" && coding !== "identity") return "atr-unfetchable"; const chunks: Uint8Array[] = []; let size = 0; for await (const chunk of response.body) { size += chunk.length; if (size > MAX_ATR_BYTES) { controller.abort(); return "atr-too-large"; } chunks.push(chunk); } const bytes = new Uint8Array(size); let at = 0; for (const c of chunks) { bytes.set(c, at); at += c.length; } return bytes; } catch { return "atr-unfetchable"; } finally { clearTimeout(timer); } } // What the seller served: the ATR's bytes at the link, and the 402 challenge that advertises their hash. const atrBytes = new TextEncoder().encode('{"atrVersion":"1","id":"0f8fad5b-d9cb-469f-a165-70867728950e","terms":"10000 units"}'); const link = "https://atr.seller.example/quote-0001"; const H = await hash(atrBytes); const challenge: PaymentRequired = { x402Version: 2, resource: { url: "https://api.seller.example/v1/quote" }, accepts: [ { scheme: "exact", network: "eip155:84532", amount: "10000", asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", payTo: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", maxTimeoutSeconds: 60, extra: { name: "USDC", version: "2" }, }, ], extensions: { legalContext: { info: { type: "sha256", value: H, legalContextUrl: link }, schema: {}, }, }, }; const sellerFetch: typeof fetch = async () => new Response(atrBytes); const paymentRequired = encodeHeader(challenge); // the 402's PAYMENT-REQUIRED header if (isRefusal(paymentRequired)) throw new Error(paymentRequired.code); // 1. Compare. const doc = decodePaymentRequired(paymentRequired); if (isRefusal(doc)) throw new Error(`decline: ${doc.code}`); const offer = exactEip3009.read(doc); if (isRefusal(offer)) throw new Error(`decline: ${offer.code}`); const served = await fetchAtr(offer.link, sellerFetch); if (typeof served === "string") throw new Error(`decline: ${served}`); if (!hashEquals(await hash(served), offer.h)) throw new Error("decline: hash-mismatch"); console.log("compared:", offer.h === H); // 2. Build and sign. const payer = privateKeyToAccount(generatePrivateKey()); const accepted = offer.offer.options[0]!; const unsigned = await exactEip3009.build( { required: doc, accepted, from: payer.address, now: Math.floor(Date.now() / 1000) }, offer.h, ); if (isRefusal(unsigned)) throw new Error(`decline: ${unsigned.code}`); console.log("signing:", unsigned.typedData.primaryType, "with nonce H:", unsigned.typedData.message.nonce === offer.h); const signature = await payer.signTypedData(unsigned.typedData as TypedDataDefinition); // 3. Finish. const payment = unsigned.complete(signature); if (isRefusal(payment)) throw new Error(`decline: ${payment.code}`); const signed = await exactEip3009.bound(payment); if (typeof signed !== "string" || !hashEquals(signed, offer.h)) throw new Error("decline: signed-not-bound"); const paymentSignature = encodeHeader(payment); // the retried request's PAYMENT-SIGNATURE header if (isRefusal(paymentSignature)) throw new Error(paymentSignature.code); console.log("finished: the payment carries H"); ``` ```text compared: true signing: TransferWithAuthorization with nonce H: true finished: the payment carries H ``` Send `encodeHeader(payment)` to the seller as the retried request's `PAYMENT-SIGNATURE` header (`PAYMENT_SIGNATURE`; [The headers](https://lcp.integraledger.com/guides/x402.md#the-headers)), and keep `served`: it is your copy of what you agreed to. ## Choosing among options A challenge may offer several options on several rails. `pairingOf(option)` names the pairing that serves each one, and each pairing's `read` returns only the options it can pay. Choose an option your accounts can pay, then use that pairing's `build`. The same H rides in whichever you choose. ## When the challenge carries an agreement URL Some pairings' payments carry H in nothing public: their `data.coverage` is `none`. `read` returns `agreement`, an `https` URL, whenever the challenge carries one. Pay it only when the chosen pairing's `data.coverage` is `none`, and pay it first, with a payment that carries H publicly. The agreement payment is approved like any other: hand the agent its amount, token, payee and network, and sign it only once the agent approves. Pay the full payment only after the agreement's `200` receipt names the same H. Where the agreement URL answers the unpaid request `202`, an agreement payment for this ATR is settling: sign nothing, and call again later without approval. See [the agreement URL](https://lcp.integraledger.com/concepts/buyer-gate.md#the-agreement-url). Pay the agreement through a pairing whose `data.agreement` is present, one whose payment can itself be an agreement, and build it as one: `build(choice, h, "agreement")`. On a pairing whose single-use value is H itself, such as `x402/exact/eip155/eip3009`, the agreement then carries the agreement's own value, `agreementValue(h)`, where a payment carries H, so the agreement and the charge under one H never share a nonce. `bound(agreement, { act: "agreement", h })` reads H back from it. ## Returning after the agreement Where the sale's charge is offered only once its agreement is recorded, the buyer's agent repeats its request after it pays the agreement, with the sale's H in the `Legal-Context` request header (profile [`legal-context-return`](https://lcp.integraledger.com/profiles/legal-context-return.md)). Over MCP, the agent sends the same value in `params._meta` under `LEGAL_CONTEXT_META`, `com.integraledger.lcp/legal-context`, on each later tool call of the sale. `toLegalContextHeader(h, returnValue?)` writes it, an RFC 9651 Item whose token is H's LCP string, with the sale's 32-byte return value as the parameter `rv` where the first response gave one; `fromLegalContextHeader(value)` reads it as RFC 9651 parses an Item, an `rv` given twice counting as the last and its base64 read with or without its padding. Send a return value only to the resource server that gave it, on the return and on every later request of the sale. `servesOf(option, atr?)` names the charge options an agreement option serves, each `/` (`x402/`, `mpp/`, `card/` and the other slots the profile lists), the option at that index of the charge options the ATR's binding slot of that name holds, so the buyer pays an agreement that serves the charge it means to pay. Given the ATR's bytes, it also refuses a name whose slot is not the ATR's binding slot or whose index is past that slot's options. ## Channels and sessions In a channel, the buyer compares once, at the opening: one ATR covers the whole channel. See [Channels, sessions and subscriptions](https://lcp.integraledger.com/guides/sessions.md). --- # x402 > The legalContext extension, the request commitment, and the x402 pairings. Source: https://lcp.integraledger.com/guides/x402 Updated 2026-11-20. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. [x402](https://github.com/x402-foundation/x402/blob/main/specs/x402-specification-v2.md) is HTTP 402 payment: the seller answers a request with a `PaymentRequired` document listing the options it accepts, and the buyer retries with a payment for one of them. This package reads and writes x402 version 2 documents. Import the x402 pieces from `@integraledger/lcp/x402`. This page is for a seller or a buyer on x402: it gives where H rides in the document and the payment, every x402 pairing, and how to read a payment's settlement. ## The `legalContext` extension Every x402 pairing advertises H in the same place: the document's `extensions.legalContext`, as x402's extension mechanism defines it (an `info` object and a JSON Schema for it). ```json no-check { "extensions": { "legalContext": { "info": { "type": "sha256", "value": "0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", "legalContextUrl": "https://atr.seller.example/b3195b1f-4115-46b2-95a3-c9d61d7bfb01" }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object" } } } } ``` `LEGAL_CONTEXT` is the extension's key and `LEGAL_CONTEXT_SCHEMA` the full schema every pairing writes. The buyer echoes `extensions` unchanged in its payment; x402 requires it to keep at least the info it received. When the seller passes an agreement URL, `info` also carries `legalContextAgreementUrl` ([the agreement URL](https://lcp.integraledger.com/concepts/buyer-gate.md#the-agreement-url)). x402's `cloudflare:402` network omits `schema` from the extensions it carries, to keep each header under 2 KB. On `x402/batch-settlement/cloudflare` the `legalContext` entry carries `LEGAL_CONTEXT_SCHEMA` as on every pairing, in `PAYMENT-REQUIRED` and again in the `PAYMENT-SIGNATURE` that echoes it. One document has one legal context. Each pairing that advertises into the same document with the same H, link and agreement URL leaves `info` as it is and writes `LEGAL_CONTEXT_SCHEMA` as its schema; a different H, link or agreement URL (one given and the other absent included) is refused as `x402/legal-context-conflict`. The comparison is of the JSON values, so a legal context naming the same H in upper case, or the link as `legal_context_url`, is refused as `x402/legal-context-conflict` too. A challenge offering options on several rails therefore carries one H, and the buyer's payment on any of them is bound to the same ATR. ## The headers `encodeHeader(value)` writes `PAYMENT-REQUIRED`, `PAYMENT-SIGNATURE` or `PAYMENT-RESPONSE` as x402's HTTP transport and its stock clients write them: padded standard base64 of the UTF-8 of `JSON.stringify(value)`, the object's members in their own order. As `@x402/core` 2.30.0 writes them, a member whose value is `undefined` is left out, at any depth, and so is a top-level `extensionResponses`, which its `PAYMENT-RESPONSE` encoder deletes. `decodePaymentRequired`, `decodePaymentSignature` and `decodePaymentResponse` read a header's value back: canonical padded base64 of well-formed UTF-8 that is a JSON object, at most `MAX_HEADER_BYTES` bytes, else `x402/header-malformed`, with `x402Version` 2 on the first two, else `x402/not-v2`. Every member is kept as it is, so an extension the package does not declare passes through untouched beside the `legalContext` extension `advertise` composes. The vectors are `x402-headers.json`. ## The request commitment `requestCommitment({ method, target, body })` commits to the request the challenge answers: the method as received, the request-target split at its first `?` into `path` and `query`, and `bodyDigest`, SHA-256 over the body bytes exactly as received. The target is at most 8 KiB of visible ASCII starting with `/`, and the body at most 1 MiB. `requestCommitment({ method, target, body, headers }, fields)` also commits to the request header fields a resource server names in `fields`, those its price or its answer rests on: for each, in the order named, its lower-cased name and SHA-256 of its value as received, never the value, a field given on several lines joined by `, ` (`cookie` by `; `), and `null` for a field the request lacks; `headers` is required where `fields` names any. With no field named there is no `headers` member. A digest of a short or common value is guessed by hashing the candidates, so name only fields whose values that does not expose, and none a proxy writes ([`x402-request-commitment`](https://lcp.integraledger.com/profiles/x402-request-commitment.md), rule 3). Over MCP, `toolCallCommitment({ name, arguments })` commits to the `tools/call` request the challenge answers: the tool's name as received and `argumentsDigest`, SHA-256 over the RFC 8785 form of its arguments, absent read as `{}`; arguments that are present and not an object, `null` among them, are refused `x402/tool-call-malformed`. `_meta`, where the payment rides on the retry, is not committed, so the paid retry has the commitment of the first call ([`x402-request-commitment`](https://lcp.integraledger.com/profiles/x402-request-commitment.md)). `tie(accepts, request)` is the ATR's binding slot for every x402 pairing: `["x402", { accepts, request }]`, with every option exactly as issued. `issuedDigest` is SHA-256 over the RFC 8785 form of one option or one commitment, for a seller that keeps a digest of what it issued. ## Advertising several options This example advertises one H into a challenge with two EVM options, one for EIP-3009 and one for Permit2, and shows which pairing serves each option: ```ts import { hash, isRefusal, pairingOf } from "@integraledger/lcp"; import { exactEip3009, exactPermit2, requestCommitment, type PaymentRequired, type PaymentRequirements, } from "@integraledger/lcp/x402"; const base: PaymentRequirements = { scheme: "exact", network: "eip155:84532", amount: "10000", asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", payTo: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", maxTimeoutSeconds: 60, extra: { name: "USDC", version: "2" }, }; const viaPermit2: PaymentRequirements = { ...base, extra: { ...base.extra, assetTransferMethod: "permit2" } }; const doc: PaymentRequired = { x402Version: 2, resource: { url: "https://api.seller.example/v1/quote" }, accepts: [base, viaPermit2], }; const h = await hash(new TextEncoder().encode("the ATR's bytes")); const link = `https://atr.seller.example/${crypto.randomUUID()}`; const first = exactEip3009.advertise(doc, h, link, base); if (isRefusal(first)) throw new Error(first.code); const both = exactPermit2.advertise(first, h, link, viaPermit2); if (isRefusal(both)) throw new Error(both.code); console.log(pairingOf(base), pairingOf(viaPermit2)); const read = exactPermit2.read(both); console.log(isRefusal(read) ? read.code : `${read.offer.options.length} option, H ${read.h === h ? "matches" : "differs"}`); const other = await hash(new TextEncoder().encode("another ATR")); const clash = exactPermit2.advertise(first, other, link, viaPermit2); console.log(isRefusal(clash) ? clash.code : "placed"); console.log(await requestCommitment({ method: "POST", target: "/v1/quote?tier=1", body: new TextEncoder().encode("{}") })); ``` ```text x402/exact/eip155/eip3009 x402/exact/eip155/permit2 1 option, H matches x402/legal-context-conflict { method: 'POST', path: '/v1/quote', query: 'tier=1', bodyDigest: '0x44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a' } ``` ## A Worker that serves one pairing `pairingOf`, from the package root, names the first x402 pairing in `BINDINGS` whose `read` offers an option, so a bundle that calls it holds every pairing. A Worker that serves one pairing need not import the root. It imports that pairing's entry point, such as `@integraledger/lcp/x402-exact-solana`, and asks the pairing itself: its `read`, on a `PaymentRequired` document holding the option and the `legalContext` extension, offers the option only if the pairing serves it, and its `bound`, on a presented payment, refuses a payment whose `accepted` the pairing's `read` does not offer. Each x402 pairing has one option filter, which its `advertise`, `read`, `build`, `bound` and `reference` apply, and which holds every check those make on the option alone: the option's own members and the widths `build` writes them into. So a pairing's `read` offers no option its `build` or `bound` then refuses for what the option says, and every refusal of a payment under an option `read` offers compares what the payer signed with the option: a carrier, a channel id, a nonce or a salt. Every x402 pairing's `bound` holds `accepted` to that filter: an option of another pairing, or of none, is `x402/option-not-this-pairing`, and an option of the pairing that its `read` does not offer is refused with the code its `advertise` gives that option. No two x402 pairings' `read` offers one option, with one case to know: - The two ERC-7710 levels share the `erc7710` option, and both offer it. `pairingOf` names `x402/exact/eip155/erc7710`; `pairingOfPayment`, from `@integraledger/lcp/x402`, names the level from the payment. ## The x402 pairings Every x402 pairing in the registry. The [pairings reference](https://lcp.integraledger.com/reference/pairings.md) states what each one proves, and [Rails](https://lcp.integraledger.com/guides/rails.md) gives the field on each chain. `Coverage` is `none` where no public ledger shows a payer-signed act carrying H: there the seller also advertises an [agreement URL](https://lcp.integraledger.com/concepts/buyer-gate.md#the-agreement-url). `Confirmed` is `yes` where something outside this package has shown the form as its profile defines it, and `no` where nothing has yet. | Pairing | Where H rides | Coverage | Confirmed | |---|---|---|---| | `x402/exact/eip155/eip3009` | The EIP-3009 authorization's `nonce`, which is H. | `full` | yes | | `x402/exact/eip155/permit2` | The Permit2 `nonce`, which is H. | `full` | yes | | `x402/exact/eip155/erc7710-salt` | The `salt` of the redeemed leaf delegation, which is H, through MetaMask's DelegationManager. | `full` | yes | | `x402/exact/eip155/erc7710` | Nothing the delegator signs: H rides only in the echoed `legalContext` extension. | `none` | yes | | `x402/exact/eip155/gateway-batched` | The nonce of the `TransferWithAuthorization` signed in Circle Gateway's `GatewayWalletBatched` domain, which is H; no public ledger shows it. | `none` | yes | | `x402/upto/eip155/permit2` | The Permit2 `nonce`, which is H, for a signed maximum. | `full` | yes | | `x402/auth-capture/eip155/eip3009`, `x402/auth-capture/eip155/permit2` | The escrow payment's `PaymentInfo.salt`: H, or, where the option binds a receiver authorizer or a policy, a digest over them and H, which travels with `saltNonce`, H. | `full` | yes | | `x402/batch-settlement/eip155` | The channel configuration's `salt`, or in the scheme's refund-authorizer mode the deposit authorization's salt or Permit2 nonce. See [Channels, sessions and subscriptions](https://lcp.integraledger.com/guides/sessions.md). | `full` | yes | | `x402/batch-settlement/solana` | The seller's Memo instruction in the channel's opening, H's LCP string (`extra.memo`). | `full` | no | | `x402/batch-settlement/cloudflare` | Nothing: Cloudflare writes the `402`, so the payment carries no H the seller issued; its echoed `legalContext` extension only locates the sale. | `none` | no | | `x402/exact/solana` | One Memo instruction, H's LCP string (`extra.memo`). | `full` | yes | | `x402/upto/solana` | The Memo instruction of the transaction that opens a one-request payment channel (`extra.memo`). | `full` | no | | `x402/exact/xrpl` | The Payment's `InvoiceID`, the SHA-256 of H's LCP string (`extra.invoiceId`). | `full` | yes | | `x402/upto/xrpl` | Nothing: the payer opens the payment channel itself, so the payment follows an agreement on the same network. | `none` | yes | | `x402/exact/hedera` | The memo of the transfer body the buyer signs, H's LCP string. | `full` | yes | | `x402/exact/hedera/transfer-executor` | Nothing the payer signs: H reaches the payer only in the extension. | `none` | no | | `x402/exact/algorand` | The asset transfer's `note`, H's LCP string. | `full` | yes | | `x402/exact/aptos` | Nothing the payer signs. | `none` | yes | | `x402/exact/cardano` | CIP-20 metadata, label 674, holding H's LCP string, to which the signed body commits. | `full` | yes | | `x402/exact/cardano/lock` | As on `x402/exact/cardano`. | `full` | yes | | `x402/exact/casper` | The CEP-3009 authorization's `nonce`, which is H. | `full` | no | | `x402/exact/ccd` | The transfer's memo, H's LCP string, in the account transaction the sender signs. | `full` | no | | `x402/exact/near` | The `memo` of the one `ft_transfer`, H's LCP string, in the NEP-366 delegate action the payer signs. | `full` | yes | | `x402/exact/polkadot/lcp-assets-remark` | `system.remark_with_event` of H's LCP string, batched with the transfer in the extrinsic the payer signs. | `full` | yes | | `x402/exact/starknet` | The SNIP-9 outside execution's `Nonce`: H's low 250 bits. | `full` | yes | | `x402/exact/stellar/precondition` | The transaction's `PRECOND_V2` extra signer: a signed payload of H and the nonce of the buyer's Soroban authorization. | `full` | yes | | `x402/exact/sui` | One `Pure` input, H's 32 bytes, that no command uses. | `full` | yes | | `x402/exact/tron/lcp-trc20-memo` | `raw_data.data`, H's LCP string, signed with the one `TriggerSmartContract`. | `full` | yes | | `x402/exact/tvm` | The forward payload's comment cell in the Jetton transfer the payer's wallet signs (`extra.forwardPayload`). | `full` | yes | | `x402/exact/lnbtc/payment-hash` | Nothing the payer signs: the ATR commits the invoice's payment hash (`extra.paymentHash`). | `none` | yes | Where the payment carries H, the payer's client writes it. The stock x402 client does so only where it copies an option member that `advertise` sets: `extra.memo` on the three Solana pairings, `extra.invoiceId` on `x402/exact/xrpl` and `extra.forwardPayload` on `x402/exact/tvm`. On every other pairing whose payment carries H, the payer uses this package's `build`, or a client of its own written to the pairing's profile. `x402/exact/casper` and `x402/exact/ccd` are not confirmed, and no stock client pays them: the stock `@x402/casper` client draws a random nonce, and the stock `@x402/concordium` client writes no memo. ## Building on x402 `build(choice, h)` takes the document, the chosen option, the payer's account and the time in Unix seconds: ```ts no-check interface X402Choice { required: PaymentRequired; accepted: PaymentRequirements; from: Hex; now: number; } ``` It returns what the buyer's signer signs, in the rail's own form, and `complete`, which turns the signer's answer into the x402 payment. On `x402/exact/eip155/eip3009` that is EIP-712 typed data; on the other EVM pairings a request whose `kind` names the form (`"eip712"`, or `"erc7710"` for a delegation); on other rails a transaction or message to sign. `build` checks H first, before it reads the choice or its document. H is your own argument, so an H that is not a valid ATR hash gets one code on every rail, whatever else the choice holds and whether or not the rail's optional peer is installed: `x402/payload-malformed`, or the code a pairing documents for it ([refusals](https://lcp.integraledger.com/reference/refusals.md)). Then it checks the form of each member of the choice that you pass besides the document and the option: a payer address, a clock, a ledger or block, a fee or nonce, a wallet's parameters. These are your arguments too, so a malformed one gets its own code on every rail, again whatever the document holds and with or without the peer. Only then does `build` read the document and the chosen option, and last it checks what compares a member with the option, such as `now` plus the option's timeout, or a token program the option names. ## Reading the payment `bound(payment)` reads H from the payment. `reference(payment, option)` gives the keys to find its settlement, with the payee of `option`, the issued option the payment answers; on `x402/exact/eip155/eip3009` they are the network, the token (`asset`), the payer, `validBefore`, H (`h`) and `presented`, the authorization's members as presented. `pairingOfPayment(payment)` names the pairing that serves a presented EVM payment. `status(ref, reader, query)` reads the act `query.act` names, `"payment"` or `"agreement"`, at the finality `query.finality` asks for, `"latest"`, `"safe"` or `"finalized"`. `query` also takes, where you have them, a final position the transaction must come after (`after`), the search position an earlier `pending` answer returned (`search`), and other acts under the same H (`others`). The read goes through an `EvmReader` you supply: `network`, the network it reads; `receipt` (`eth_getTransactionReceipt`); `blockNumber` for the `safe` and `finalized` marks; `transaction` (`eth_getTransactionByHash`); `call` (`eth_call` at a block number); and, where you give them, `logs` (`eth_getLogs`) and `block` (`eth_getBlockByNumber`). The read searches for the act only through `logs`, and knows the latest head and each head's time only through `block`: without them it gives no `failed` answer that rests on a search or a lapse, and no `instrument-live`. Where the facilitator's settle answer names the transaction, add it to the reference as `transaction`. It is read beside the search, and is never required. `status` answers `settled`, `pending`, `failed` or `unreadable`, with one reason of the closed list the [read-status profile](https://lcp.integraledger.com/profiles/read-status.md) states: | State | Reasons | |---|---| | `settled` | None: the answer names the transaction, the finality it reached, and `presented`. | | `pending` | `below-mark`, `instrument-live`, `search-incomplete`, `not-found` | | `failed` | `instrument-unused`, `instrument-consumed`, `transaction-failed`, `before-position` | | `unreadable` | `history-gap`, `transport`, `unparseable`, `too-large`, `chain-mismatch` | Every answer also lists the foreign items the read met: transactions that carry H and are not the act, each with its reason. A `pending` answer can carry `search`, the position to pass back as `query.search`. It settles on a transaction that carries H, was signed by the reference's payer and, for a payment, pays the option's payee, read at the finality asked for or above it; below it, the answer is pending `below-mark`. The amount is not compared: `presented` on a settled answer says whether the landed act is the payment presented. `failed`, for any reason but `before-position`, comes only from a read at the `finalized` mark and, at coverage `full`, only once the search for H is read whole. A reader call that rejects makes the answer `unreadable`, never `failed`, and so does a reader that declares another network (`chain-mismatch`). A missing or malformed query or reference is `unreadable`, `unparseable`, with nothing read. [Reading settlement](https://lcp.integraledger.com/guides/rails.md#reading-settlement) gives the rules rail by rail. ### What counts as the act | Pairing | The act `status` settles on | |---|---| | `x402/exact/eip155/eip3009` | The token's `AuthorizationUsed` whose nonce is H, from the reference's payer, paired with its `Transfer`: by the token's two logs where the transaction holds one use and at most one transfer of that authorizer on that contract, and otherwise by the one call that consumed it, decoded. The transfer pays the option's payee. | | `x402/exact/eip155/permit2`, `x402/upto/eip155/permit2` | A call to the scheme's Permit2 proxy whose nonce is H, found at any byte offset of the transaction's input, with that proxy's `Transfer` of the call's token from its owner to its witness's `to`, and the owner's Permit2 bit for the nonce set at the receipt's block and unset at the block before. | | `x402/exact/eip155/erc7710-salt` | A `RedeemedDelegation` from the DelegationManager for a leaf delegation, one whose delegate is the redeemer or the wildcard delegate, with salt H, and a `Transfer` from its root delegator, the reference's payer, to the option's payee. | | `x402/exact/eip155/erc7710` | The transaction the reference names, holding a `Transfer` from the payment's delegator to the option's payee. Nothing in it ties it to this payment, so give `query.after`, the position of the agreement's own settlement, which the transaction must come after. | | `x402/auth-capture/eip155/eip3009`, `x402/auth-capture/eip155/permit2` | The escrow's `PaymentAuthorized` or `PaymentCharged` event, the option's flow's, through the deployment's collector for the pairing's scheme, whose `PaymentInfo.salt` is the reference's and whose `receiver` is the option's payee. | | `x402/batch-settlement/eip155` | The deposit into the reference's channel; see [Channels, sessions and subscriptions](https://lcp.integraledger.com/guides/sessions.md#reading-settlement). | ### Before a transaction is named On the pull pairings, where the payer signs an authorization that someone else executes later (`x402/exact/eip155/eip3009`, `x402/exact/eip155/permit2`, `x402/upto/eip155/permit2`, `x402/auth-capture/eip155/eip3009` and `x402/auth-capture/eip155/permit2`), `status` reads the authorization's single-use value at the final mark and, through a reader that has `block`, at the latest head. It answers pending `instrument-live` while the authorization reads unused at both and is still valid. Once it has lapsed unused, the answer is failed `instrument-unused` where the search is whole, and pending `search-incomplete` otherwise. On the `auth-capture` pairings the signed nonce is a digest over more than H, so the search is never whole. `authorizer(payment)` gives the account whose signature authorises the pull, as lowercase hex. `authorizationUsed({ network, authorization }, authorizer, block, reader)`, from `@integraledger/lcp/evm`, asks the contract that records the use whether the authorization had executed by a given block. The x402 references carry no `authorization`, so build it from the reference: | Member | Value | |---|---| | `scheme` | `"eip3009"` or `"permit2"`, the authorization's kind (`ref.scheme` on `auth-capture`). | | `at` | The contract that records the use: the token, `ref.asset`, for EIP-3009; `PERMIT2`, from `@integraledger/lcp/evm`, for Permit2. | | `nonce` | The nonce the payer signed: `ref.h` on the `exact` and `upto` pairings, `ref.signatureNonce` on `auth-capture`. | | `deadline` | The signed bound: `ref.validBefore` on EIP-3009, `ref.deadline` on Permit2, `ref.expiry` on `auth-capture`. | | `asset` | `ref.asset`. | [The seller guide](https://lcp.integraledger.com/guides/seller.md#the-whole-flow) builds it for EIP-3009. An EIP-3009 authorization executes only while the block's timestamp is below `deadline`, and a Permit2 permit only while it is at most `deadline`. `x402/exact/eip155/erc7710-salt` gives `authorizer`, the delegator of the permission context's root delegation, and no single-use value: a delegation records no nonce and names no deadline. --- # MPP > The ATR hash as the MPP challenge id, the opaque members, and the MPP pairings. Source: https://lcp.integraledger.com/guides/mpp Updated 2026-11-20. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. MPP, the Machine Payments Protocol, carries payment in HTTP authentication, as the [Payment HTTP authentication scheme](https://paymentauth.org) defines it: the seller answers with one or more `WWW-Authenticate: Payment` challenges, each naming a `method` (such as `evm`, `tempo`, `solana`, `stripe` or `lcp`) and an `intent` (`charge`, `session` or `subscription`), and the buyer answers with a credential that echoes the challenge it pays. Import the MPP pieces from `@integraledger/lcp/mpp`. This page is for a seller or a buyer on MPP: it gives where H rides in a challenge, how to place and read it, every MPP pairing, the checks a resource server makes before money moves, and how to answer the buyer. ## Where H rides On every MPP pairing, H rides in the challenge itself, in two places: - **The challenge `id`** is the base64url (no padding) of H's 32 bytes, then `.` and the challenge's position, 0 to 31, which the seller gives each challenge of the sale, its charge and agreement challenges together. A Tempo `subscription` challenge's id is the bare base64url of H, so a 402 that carries H holds one Tempo `subscription` challenge at most: `place` refuses a Tempo `subscription` challenge in a 402 that holds another (`mpp/witness-taken`). The `mppx` SDK's `tempo.subscription()` offers one subscription challenge per currency, by default two on Tempo's mainnet and testnet; a seller placing H there names one `currency`. `challengeId(h, index)` writes the id and `challengeH(id)` reads H back. - **The challenge's `opaque`** map carries `legalContext`, H's LCP string, and `legalContextUrl`, the link. Where the pairing's payment carries H in nothing public, it also carries `legalContextAgreementUrl`. MPP binds the credential to the challenge it echoes, so whatever the payer signs over the challenge id, or over a value derived from it, commits to H. Some methods also carry H in a request member; `CARRIER` names that member for each intent and method. Where the payer signs it, as `externalId` on `solana` charges and `methodDetails.invoiceId` on `xrpl`, it is in the payment. The package reads a challenge's `id`, `request` and `opaque` as base64url without padding in its canonical form only (RFC 4648 §3.5). One with `=` padding, or whose last character has a bit set past its last byte, is malformed: `mpp/id-not-ours`, `mpp/request-malformed` and `mpp/opaque-malformed`, on every pairing. `read` passes over a challenge whose `id` or `opaque` is in such a form, as it passes over one that carries no hash. `issuedDigest(challenge)` is the digest of what the seller issued: SHA-256 over the RFC 8785 form of the bound members, with `request` decoded and its `CARRIER` member left out, and `opaque` without the LCP members. The seller compares the echoed challenge's digest with the one it recorded at issue. On a pairing whose quote or invoice the seller writes after H (`mpp/charge/nearintents`, `mpp/charge/lightning` and `mpp/session/lightning`), `issuedDigest` and `tie` read the challenge as the pairing's `unplaced` gives it, without the members written after H, so the challenge sent once they are written has the digest of the one the ATR binds. A credential whose echoed `opaque` is the object of its members, as `mppx` releases before 0.6.4 write it, is read by those members, as the base64url form is. ## Placing and reading `place(doc, h, link, option, position, act?, agreementUrl?)` is the seller's placement over a list of challenges: the challenge whose bound members equal `option` gets the id derived from H at `position` and an `opaque` holding the seller's own map plus the LCP members. `place` writes only the id and `opaque`. On a method whose request carries H in a member that `CARRIER` names, such as `externalId` on Solana, `methodDetails.invoiceId` on the XRP Ledger, `methodDetails.splits` on Tempo and `methodDetails.metadata.legal_context` on Stripe, use the pairing's `advertise`, which writes that member too. `act` is `"payment"`, the default, or `"agreement"`. The seller gives each challenge of a sale its own position, 0 to 31, its charge challenges and its agreement challenges together, since an agreement challenge is sent in a response of its own; a Tempo `subscription` challenge takes `null`. A position that another challenge of the list already carries is `mpp/position-taken`. `place`, and so each pairing's `advertise`, which takes the same arguments, refuses a list holding a challenge that carries a `refused` member as `mpp/challenge-malformed`. `read(doc)` is the buyer's reading: the challenges whose `opaque` carries an LCP hash and an `https` link and whose id derives from that hash. `pairingsOf(challenge)` names the pairings a challenge offers, and `pairingsOfPlaced(challenge)` those a placed challenge offers, with the Lightning invoice the seller's node writes after `place` required. `tie(challenges)` is the ATR's binding slot: every challenge's bound members, as issued. A challenge's `expires`, when present, is an RFC 3339 date-time, else `mpp/expires-required`. MPP's core makes it a SHOULD for servers. A pairing needs it where its `build` writes it into what the payer signs: the EVM `authorization` and `permit2` charges, the `usdc` EVM charge and the EVM and Tempo sessions; the NEAR Intents and XRP Ledger charge drafts require it too. Without `expires` those pairings are left out of what `pairingsOf`, `advertise`, `build`, `bound` and `reference` take, and a challenge left with no pairing is `mpp/expires-required`. The `lcp` method's filter also refuses a charge challenge without it (`mpp/charge/lcp/hedera`). ```ts import { hash, isRefusal } from "@integraledger/lcp"; import { challengeH, pairingsOf, place, read, type MppChallenge } from "@integraledger/lcp/mpp"; const request = Buffer.from( JSON.stringify({ amount: "10000", currency: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", methodDetails: { chainId: 84532, credentialTypes: ["permit2", "authorization"], permit2Address: "0x000000000022D473030F116dDEE9F6B43aC78BA3", }, recipient: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", }), ).toString("base64url"); const issued: MppChallenge = { id: "issued-by-the-seller", realm: "api.seller.example", method: "evm", intent: "charge", request, expires: "2026-09-21T14:14:20Z", }; console.log(pairingsOf(issued)); const h = await hash(new TextEncoder().encode("abc")); const placed = place([issued], h, "https://atr.seller.example/b3195b1f-4115-46b2-95a3-c9d61d7bfb01", issued, 0); if (isRefusal(placed)) throw new Error(placed.code); const id = placed[0]!.id!; console.log(id, challengeH(id) === h); console.log(Buffer.from(placed[0]!.opaque!, "base64url").toString()); const offer = read(placed); if (isRefusal(offer)) throw new Error(offer.code); console.log(offer.h === h, offer.offer.challenges.length); ``` ```text [ 'mpp/charge/evm/permit2', 'mpp/charge/evm/authorization' ] ungWv48Bz-pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0.0 true {"legalContext":"lcp:sha256:0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad","legalContextUrl":"https://atr.seller.example/b3195b1f-4115-46b2-95a3-c9d61d7bfb01"} true 1 ``` ## The fields MPP carries its three forms in HTTP fields, and the package writes and reads each as the `mppx` SDK (0.17.6) does: - `encodeChallenge(challenge)` writes one challenge as a `WWW-Authenticate` field value: `Payment`, then each member the challenge holds as a quoted-string, in the order `id`, `realm`, `method`, `intent`, `request`, `description`, `digest`, `expires`, `header`, `opaque`. It writes the members as given, `request` and `opaque` in the base64url `place` and `advertise` write, and only a value `parseChallenges` reads back as the same members: a challenge missing `id`, `realm`, `method`, `intent` or `request`, or holding one empty, a `header` other than `Payment-Authorization`, the one value MPP allows it, a member holding a control character or a character above U+00FF, which no quoted-string carries, or a value over 8,192 characters is `mpp/challenge-malformed`. A 402 offering several challenges sends one `WWW-Authenticate` field line for each. `parseChallenges(fieldValues)` parses `WWW-Authenticate` field values into challenges. - `decodeCredential(fieldValue)` reads the credential from the field the challenge selected, `Authorization`, or `Payment-Authorization` where the challenge carries `header`: `Payment`, in any case, one or more spaces and the credential's JSON in base64url without padding, at most 65,536 bytes, held to the shape every `bound` reads first. Any other value is `mpp/credential-malformed`. It reads nothing else: the challenge's id and H are `challengeBound`'s to check ([The server's order](https://lcp.integraledger.com/guides/mpp.md#the-servers-order)). - `encodeCredential(credential)` writes the value a buyer's client sends in that field, which `decodeCredential` reads back, as `mppx` writes it: `Payment`, a space and the credential's JSON in base64url without padding, the challenge's members in their order with `opaque` and then `request` last, then `payload`, then `source`. It leaves out the echoed challenge's `meta` and an empty `source`, as `mppx` does, and writes every other member as given. A credential `decodeCredential` would refuse, or one that is not JSON (a `bigint`, an `undefined` inside the payload), is `mpp/credential-malformed`. - `encodeReceipt(receipt)` writes the `Payment-Receipt` field value of a successful response: the receipt's JSON, in its own member order, in base64url without padding. A receipt whose `status` is not `success`, whose `method` is not lowercase ASCII letters, whose `timestamp` is not an RFC 3339 date-time or whose `reference` is not a string is `mpp/receipt-malformed`. A method's own receipt members, such as `externalId`, are written as given. - `decodeReceipt(fieldValue)` reads the receipt a buyer's client finds in a successful response's `Payment-Receipt` field: base64url without padding in its canonical form, at most 65,536 bytes (`MAX_HEADER_BYTES`), of a JSON object that `encodeReceipt` would write, every member kept as given. Any other value, a longer or padded one among them, is `mpp/receipt-malformed`. The receipt is what the seller reports; it reads no payment. `problem(code)` gives the Payment scheme's problem type and HTTP status for a refusal code this package returns ([Answering the buyer](https://lcp.integraledger.com/guides/mpp.md#answering-the-buyer)). ## The MPP pairings Every MPP pairing in the registry. `Confirmed` is `yes` where something outside this package has shown the form as its profile defines it, and `no` where nothing has yet. | Method | Pairings | Where H rides in what the payer signs or lands | Confirmed | |---|---|---|---| | `evm` | `mpp/charge/evm/authorization` | The EIP-3009 nonce: keccak256 of the challenge id and realm (`challengeHash`). | yes | | `evm` | `mpp/charge/evm/permit2` | The Permit2 witness's `challengeHash`, keccak256 of the challenge id and realm. | no | | `evm` | `mpp/charge/evm/transaction`, `mpp/charge/evm/hash` | Nothing signed or landed; H is in the challenge. On `transaction`, `build`'s `complete` takes an EIP-1559 transaction, else `mpp/credential-malformed`, signed for the challenge's `methodDetails.chainId`, else `evm/chain-mismatch`, as draft-evm-charge-00's transaction verification reads it. | yes | | `tempo` | `mpp/charge/tempo/split-memo` | The memo of the one `transferWithMemo` call to `currency` whose memo is H: the split `{recipient, amount: "1", memo: H}` that the pairing's `advertise` appends to `methodDetails.splits`, and that the stock client copies into the transaction the payer signs. The resource server's settler broadcasts it. | yes | | `tempo` | `mpp/charge/tempo/split-memo/push` | As on `mpp/charge/tempo/split-memo`, in a transaction the payer broadcasts and names by its hash, which `fetchPresented` reads. | yes | | `solana` | `mpp/charge/solana`, `mpp/charge/solana/unsponsored` | The one LCP-form Memo instruction, holding H's LCP string (the request's `externalId`); other Memo instructions, such as split labels, are not read. The first pairing is a challenge whose `methodDetails.feePayer` is `true`, the second any other. | yes | | `xrpl` | `mpp/charge/xrpl` | The Payment's `InvoiceID`: H itself (the request's `methodDetails.invoiceId`), in a Payment the payer signs with a single key. The Payment carries no `NetworkID`: each network the challenge names has an id of at most 1024, where rippled refuses one, so a blob that carries it is `xrpl/network-mismatch`, which `build`'s `complete`, reading the blob as `bound` does, also gives. | yes | | `lightning` | `mpp/charge/lightning` | The BOLT11 invoice's description hash `h`, which the seller's node signs. | no | | `usdc` | `mpp/charge/usdc/evm`, `mpp/charge/usdc/gateway` | The EIP-3009 nonce, or the Gateway burn intent's salt: `usdc`'s derivation over the challenge id. | yes: `mpp/charge/usdc/evm`; no: `mpp/charge/usdc/gateway` | | `usdc` | `mpp/charge/usdc/solana`, `mpp/charge/usdc/stacks` | The signed LCP-form Memo instruction (H's LCP string), or the SIP-010 `transfer` memo (H's 32 bytes). The Stacks transaction is signed for the challenge's `chainId`, which `build`'s request names, at that network's version, 0x00 on chain 1 (mainnet) and 0x80 on any other, as a Stacks node requires, else `stacks/chain-mismatch`, which `build`'s `complete` also gives it. | yes: `mpp/charge/usdc/solana`; no: `mpp/charge/usdc/stacks` | | `nearintents` | `mpp/charge/nearintents` | The request's `externalId`; the deposit carries nothing. | no | | `lcp` | `mpp/charge/lcp/hedera` | The memo of the `TransferTransaction` body the buyer signs, H's LCP string, on the method's `hedera` rail. `methodDetails.supportedModes` must be `["pull"]` (`mpp/modes-not-pull`), and the challenge must state `expires`; the LCP profile [`mpp/method/lcp`](https://lcp.integraledger.com/profiles/mpp-method-lcp.md) states the rules. | yes | | `card`, `stripe` | `mpp/charge/card`, `mpp/charge/stripe`, `mpp/subscription/stripe` | The request's `externalId`, or `methodDetails.metadata.legal_context`, which on a `stripe` charge the seller's server copies into the PaymentIntent it creates at settlement; MPP's Stripe subscription method does not say where the metadata goes. The buyer's card or token signs nothing that carries H. | no | | sessions | `mpp/session/evm`, `mpp/session/tempo`, `mpp/session/xrpl`, `mpp/session/lightning`, `mpp/session/solana/memo` | Where the channel opens. See [Channels, sessions and subscriptions](https://lcp.integraledger.com/guides/sessions.md). | yes: `mpp/session/tempo`; no: `mpp/session/evm`, `mpp/session/xrpl`, `mpp/session/lightning`, `mpp/session/solana/memo` | | sessions | `mpp/session/xrpl/stock`, `mpp/session/solana/stock`, `mpp/session/hedera/stock` | Nothing: the stock client opens the channel, so the session is served only after an agreement on its own network (coverage `none`), and `bound` refuses `mpp/no-signed-place`. | yes: `mpp/session/solana/stock`; no: `mpp/session/xrpl/stock`, `mpp/session/hedera/stock` | | subscription | `mpp/subscription/tempo` | The key authorization the payer's root key signs, whose witness is H. | yes | | subscription | `mpp/subscription/solana` | The Memo instruction of the activation, H's LCP string (the request's `externalId`). | no | On `mpp/charge/nearintents`, both Tempo charges, the three stock sessions and `mpp/subscription/solana`, the payer's own client builds the payment, and the pairing has no `build`. `challengeHash` is keccak256 of the UTF-8 of `JSON.stringify([id, realm])`: the id and realm framed as a JSON array of two strings, as the `mppx` SDK computes it from 0.13.1, so that no two pairs share a preimage (`"ab"` and `"c"`, `"a"` and `"bc"`). MPP's EVM charge draft (draft-evm-charge-00) still writes `abi.encodePacked(id, realm)`, the bare concatenation; a credential signed over that form is `mpp/nonce-not-challenge-hash`, or `mpp/witness-not-challenge-hash` for `permit2`. The challenge's `id` and `realm` are hashed as UTF-8. A string holding a lone surrogate has no UTF-8 form, so a challenge whose `realm` is not a well-formed string is `mpp/challenge-malformed` in `pairingsOf`, `place` and `build`, and in every `bound`, and in each `reference` and `fetchPresented` that reads H from a credential's echoed challenge. An `id` that is not a well-formed string derives from no H: every `bound`, and every `build`, refuses it `mpp/id-not-ours`. Each pairing that this package builds for has a `build(choice, h)`, which takes the chosen challenge (`MppChoice`) and returns what the buyer signs; on card and Stripe, where nothing the buyer signs can carry H, it refuses `mpp/no-signed-place`. Its `bound(credential)` reads H from the echoed challenge and, where the payer signs a value that carries it, checks that value; where nothing signed carries H, the card, Stripe and EVM `transaction` and `hash` pairings and the three stock sessions (`mpp/session/solana/stock`, `mpp/session/xrpl/stock` and `mpp/session/hedera/stock`) refuse `mpp/no-signed-place`. `reference` and `status` read the settlement where the method lands on a chain. In push mode, where the buyer broadcasts and presents only the transaction's hash or signature, `fetchPresented(credential, reader)` reads the landed transaction first, and refuses one that failed: `svm/err` on Solana, which it gives only once a read at `finalized` holds the transaction with its error (`svm/not-final` when the error is at `confirmed` and that read does not hold the transaction yet), and `xrpl/not-success` on the XRP Ledger, which it reads only once the transaction is in a validated ledger (`xrpl/not-validated` before that). A read that fails, cannot yet read the landed payment, or reads a revert or error that is not final yet is a read to repeat, not a refusal of the payment: the seller asks again later. `readToRepeat(code)`, from the package root, is true for each such code ([Reads to repeat](https://lcp.integraledger.com/concepts/refusals.md#reads-to-repeat)). `fetchPresented` returns the credential with what it read written under one member, keyed by the registered symbol `FETCHED`, `Symbol.for("@integraledger/lcp/fetched")`, which `@integraledger/lcp`, `@integraledger/lcp/mpp` and `@integraledger/lcp/hedera` export: the landed transaction on the Solana charge, and the signed blob on the XRP Ledger charge. `bound` and `reference` read the seller's read from that member and from no other. A credential's own push `transaction` or `blob` member, or any other string-keyed member, is never read: a credential that arrives with one gives the answer the same credential without it gives, `/read-first` where the read is needed. No wire form carries a symbol-keyed member: `JSON.parse` makes none, and `JSON.stringify` and `structuredClone` drop it. So the seller keeps the object `fetchPresented` returned, or a spread or `Object.assign` copy of it, both of which copy the member; a copy made through JSON or `structuredClone` is read as a credential `fetchPresented` has not read. Calling `bound` first, and `fetchPresented` when it answers `/read-first`, reads only what the seller's reader read. `mpp/charge/evm/authorization`, `mpp/charge/evm/permit2` and `mpp/charge/usdc/evm` are pull pairings: the payer signs an authorization that the server executes later. Each gives `authorizer(credential)`, the account whose signature authorises the pull, and its reference's `authorization` names the nonce the payer signed (the challenge-derived value, not H), the deadline, the token and the contract that records the nonce's use, for `authorizationUsed` in `@integraledger/lcp/evm`. `status` on `mpp/charge/evm/permit2` counts a Permit2 witness transfer of the payer's, found at any byte offset of the transaction's input, that carries that nonce or the challenge's witness word, where the receipt holds its `Transfer`s and the payer's bit for the nonce is set at the receipt's block and unset at the block before, as on x402's Permit2 pairings. `reference(credential, challenge)` and `status(ref, reader, query)` take and answer as on x402: `status` answers `settled`, `pending`, `failed` or `unreadable`, with one reason of the closed list [the x402 guide](https://lcp.integraledger.com/guides/x402.md#reading-the-payment) gives. On the EVM and `usdc` EVM charges, it answers `failed` (`transaction-failed`, `instrument-consumed`, `instrument-unused` or `before-position`) only from a read at the reader's `finalized` mark and, where the payer's signed act carries H, only once the search is whole. A failed result read above that mark is pending `below-mark` ([Reading settlement](https://lcp.integraledger.com/guides/rails.md#reading-settlement)). The LCP profile [`mpp/charge`](https://lcp.integraledger.com/profiles/mpp-charge.md) states where each charge carries H. ### How the pairings hold a challenge and a credential `bound`, `reference` and `fetchPresented` start from the echoed challenge's H, require its intent and method to be the pairing's, and hold the echoed challenge to the pairing's filter: `pairingsOf`'s checks over it as placed, which must name the pairing (`pairingsOfPlaced`). A challenge those checks refuse gives their code, and one that offers only other pairings (another credential type, mode or `usdc` profile, or no `expires` where the pairing needs it) is `mpp/not-this-pairing`, as `advertise` and `build` answer for the same challenge. Every MPP `build` that takes a chosen challenge holds it as `bound` holds an echoed one, before it builds anything. It reads the challenge as `bound` reads its JSON form: a snapshot of its own members (`realm`, `method`, `intent`, `request`, `id`, `expires`, `digest`, `description`, `header` and `opaque`), so a member the challenge inherits counts as absent. It reads the challenge only from that snapshot, and the credential its `complete` returns carries the snapshot, so a change made to the caller's challenge after `build` does not reach the credential. Each fault in the challenge gets `bound`'s code, in `bound`'s order: a challenge that is not an object, is not challenge-shaped or has no string id, or whose least credential, `{ challenge, payload: {} }`, is over the credential size bound (`mpp/credential-malformed`); its realm; an id that derives from H; an `opaque` that names that H (else `mpp/opaque-not-this-hash`); its request; its intent and method; and the same filter. An id that derives from an H other than the one `build` is given is then `mpp/id-not-ours`. A fault in an argument other than the challenge keeps the build's own code: a choice that is not an object (`mpp/input-malformed`, or `svm/input-malformed` on the Solana charges and `mpp/credential-malformed` on Lightning), and the payer, token domain, spender, deposit and each other value the choice carries. So no `complete` is handed a challenge `bound` refuses. `pairingsOf` makes every check `build`, `bound` and `reference` make on the challenge alone: on Lightning, that the invoice decodes strictly, as `decodeBolt11` decodes it, with one `h` field and no `d`, carries the request's payment hash and the currency of the `network` the challenge names, and expires no earlier than the challenge; on the Solana charges, no `splits` or `confidential` transfer and the form of the `decimals`, `tokenProgram` and `recentBlockhash` the build writes; on Permit2, an `amount` above its `splits`; on the XRP Ledger charge, no `memos`; the XRPL session recipient's checksum; the Tempo subscription's period and expiry within the key authorization's uint64; and, on `usdc`'s EVM and Gateway profiles, a request in its RFC 8785 form. So no pairing binds a payment presented under a challenge `pairingsOf` would not name for it. Of a challenge the filter takes, each function reads only the request members its own read keys or derivation use, such as the network or chain, the currency, the recipient, the escrow, the member that carries H, and `expires` where it is the payment's deadline; on the Lightning charge and session, the read keys name the network of the invoice's currency. The EVM `transaction` and `hash` charges' `bound` then refuses a credential of another type (`mpp/credential-type`) and every other (`mpp/no-signed-place`), and a `fetchPresented` given a signed transaction returns it as given. The `complete` of each `build` that makes a credential measures it as `bound` measures every credential, its echoed challenge included, and refuses one over the credential size bound, 64 KiB, with `mpp/credential-malformed`, the code `bound` gives it, whatever the challenge's own size. It holds the payment it carries to the size `bound` reads it at too: the XRP Ledger charge's signed blob to 8,192 hex digits, the stock server's bound (`xrpl/blob-too-large`). So no `build`'s `complete` returns a credential `bound` refuses for its size. It checks in `bound`'s order, measuring the credential before it reads the payment: a payment fault in a credential over the bound, such as a `usdc` Stacks transaction over 16,384 bytes or a Tempo key authorization over 8,192 bytes, is `mpp/credential-malformed`, as `bound` gives it. One rule covers the credentials in a channel too: a `buildWithin`'s `complete` measures the in-channel credential it would return, and a session pairing's `channel.kind`, `channel.ref` and `channel.boundWithin` measure the payment they are given before they read it, with the same bound and code, except the Stripe subscription's, which read only the activation receipt. ## The server's order A resource server makes two checks a stock MPP server does not make, and makes them before anything can move money ([`mpp/charge`](https://lcp.integraledger.com/profiles/mpp-charge.md), rule 10): 1. **The challenge belongs to this agreement.** `challengeBound(credential, recorded)`, given the credential `decodeCredential` reads from the request, gives `{ h, request }`, H and the echoed challenge's decoded request, where the echoed challenge's id and `opaque` name H and the id is, whole, `recorded`, the id the server recorded when it issued that challenge (else `mpp/id-not-ours`; a `recorded` that is not such an id is `mpp/input-malformed`); and `issuedDigest` of the echoed challenge equals the digest the server recorded for H: from the ATR's binding slot (`tie`), or, for an agreement challenge, which no slot holds, the digest it recorded for its agreement option. `place(doc, h, link, option, position, "agreement", agreementUrl)`, and each pairing's `advertise` given the same arguments, composes an agreement challenge only where it states `expires` (else `mpp/expires-required`); composed anew once that `expires` has passed, in the position of the one it replaces, it keeps that challenge's id, and a credential of the replaced challenge is refused at `issuedDigest`. 2. **The payment carries H.** The pairing's `bound`, which checks how the credential carries H, or its link, and never what the payment pays. For a credential whose payer already broadcast the payment, `fetchPresented` reads the landed transaction first, and `bound` refuses `/read-first` until then. Where the payer signs nothing that carries H (`card`, `stripe`, an EVM `transaction` or `hash`, and the three stock sessions, `mpp/session/solana/stock`, `mpp/session/xrpl/stock` and `mpp/session/hedera/stock`), `bound` refuses `mpp/no-signed-place`, and the second check is the pairing's `link` and the server's own record that the agreement for this H is recorded. Then validation that moves nothing, where the method's library separates it; then the server's own record that this H's agreement or payment is now taken, once for each H and act; and only then any call that can move money. The vectors are `mpp-server-checks.json`. `toX402(credential, token, issued)` maps an `evm` `authorization` credential or a `usdc` EVM credential to x402's `exact` EIP-3009 `PaymentPayload` and `PaymentRequirements`, so a resource server that already runs an x402 facilitator settles it there as step 4 ([`mpp/charge`](https://lcp.integraledger.com/profiles/mpp-charge.md), rule 12). `token` is the token's EIP-712 `{name, version}`, which no MPP challenge carries, and `issued` the Unix second at which the server issued the challenge: `maxTimeoutSeconds` is the challenge's `expires` less `issued`. Any other credential is `mpp/no-x402-twin`; a challenge with no `expires` is `mpp/expires-required`. ## Answering the buyer `problem(code)` maps a refusal code this package returns to the Payment scheme's status codes and problem types, under `https://paymentauth.org/problems/`: | Code | Status | Problem type | |---|---|---| | `mpp/credential-malformed`, `mpp/request-malformed`, `mpp/opaque-malformed` | 402 | `malformed-credential` | | `mpp/id-not-ours` | 402 | `invalid-challenge` | | A read to repeat, a code `readToRepeat` answers true for: each rail's `/not-found` and `/unreadable` (such as `tempo/not-found` and `svm/unreadable`), `casper/not-executed`, `ccd/not-finalized`, `xrpl/not-validated`, `evm/not-final`, `polkadot/not-final`, `stacks/not-final`, `starknet/not-final`, `svm/not-final` and `tempo/not-final` | 500 | `internal-payment-error` | | A call that cannot read the payment: `tempo/wrong-reader`, `svm/wrong-reader`, `xrpl/wrong-reader`, `hedera/wrong-reader`, `tempo/read-first`, `svm/read-first`, `xrpl/read-first`, `hedera/read-first` | 500 | `internal-payment-error` | | Every other code this package returns | 402 | `verification-failed` | | A code this package does not return | 500 | `internal-payment-error` | A read to repeat is a code `readToRepeat` answers true for, such as what a `fetchPresented` or `recover` returns when its read fails, cannot yet read the landed payment, or reads a revert, an error or a verdict that is not final yet: the seller asks again later ([Reads to repeat](https://lcp.integraledger.com/concepts/refusals.md#reads-to-repeat)). A call that cannot read the payment is the seller's own call: a reader that is not for the network the challenge or reference names, or an input `recover({ network, tx, option }, reader)` cannot read: one that is not an object, or whose `tx` is not in its rail's form (a 32-byte hash on Tempo, a signature, base58 of 64 bytes, on Solana, 64 hex digits on XRPL) (`/wrong-reader`), or `bound` or `reference` on a push credential before `fetchPresented` has read it (`/read-first`). The same call gives the same code until the seller changes it. In both, the payment may already have moved, so the seller sends no fresh challenge the buyer could pay a second time. Answer a 402 with a fresh challenge and a 500 with none: a challenge goes out only with a 402, and neither carries `Payment-Receipt`, which only a successful response carries (`encodeReceipt`). Any other code is the caller's to answer: `problem` gives it 500 `internal-payment-error`, never a 402. --- # Channels, sessions and subscriptions > One ATR for a whole channel, session or subscription, bound where it opens. Source: https://lcp.integraledger.com/guides/sessions Updated 2026-11-20. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. Some payments are not one-off. An x402 `batch-settlement` channel takes a deposit and then pays each request with a voucher. An MPP `session` does the same with a payment channel, and an MPP `subscription` activates once and renews each period. Paying request by request under a fresh ATR each time would make every voucher an agreement of its own. These pairings bind **one ATR to the whole channel, session or subscription**. H rides where the channel opens: in its salt, its memo, the authorization that activates it, the deposit invoice's description hash on Lightning, or the request's metadata on Stripe; on the three stock sessions nothing carries it, and the session is served only after an agreement. The later payments within it carry no ATR of their own. Another agreement opens another channel. This page gives each channel pairing, the members a channel adds, a program that runs one channel end to end, and how its settlement is read. ```mermaid sequenceDiagram participant B as Buyer participant S as Seller S-->>B: challenge carrying H and the link Note over B: buyer gate: fetch, compare with H, once B->>S: the opening, with H in its salt, memo or witness Note over S: bound(opening) equals the H it issued, channel.kind is open loop each later request B->>S: a voucher within the channel Note over S: channel.kind is within, channel.ref names the same channel end B->>S: the close Note over S: channel.kind is close ``` The buyer compares the served bytes with H once, at the opening. After that, a payment within the channel is tied to the ATR through the channel it belongs to. ## The pairings Thirteen pairings have a `channel` member. The table says where H rides at the opening, which later payments count as within the channel, what `channel.boundWithin` and `channel.until` read, and whether the form is confirmed: `yes` where something outside this package has shown it as its profile defines it. Four are confirmed: `x402/batch-settlement/eip155`, `mpp/session/tempo`, `mpp/session/solana/stock` and `mpp/subscription/tempo`. | Pairing | H at the opening | Within, and the close | `boundWithin` | `until` | Confirmed | |---|---|---|---|---|---| | `x402/batch-settlement/eip155` | The channel configuration's `salt`. The channel id, which the deposit authorization and every voucher sign, commits to it. In the scheme's refund-authorizer mode (`extra.voucherManager` `"facilitator"` with a non-zero `extra.refundAuthorizer`), the channel salt packs entropy and the refund authorizer, and H is the deposit authorization's salt or the Permit2 deposit's nonce. | A voucher, or a refund whose amount is a positive decimal below 2^128, is within; a full refund, which names no amount, is the close. | The `salt` of the payment's channel configuration, once it hashes to the voucher's channel id. In the refund-authorizer mode it refuses `x402/not-bound-within`, because only the opening carries H. | none | yes | | `x402/batch-settlement/solana` | The opening transaction's seller Memo instruction, H's LCP string (the option's `extra.memo`), beside x402's receiver-authorizer binding memo. | A voucher or a top-up is within; a refund is the close. | Refuses `x402/not-bound-within`. | none | no | | `mpp/session/evm` | The channel's `salt`: in the signed `open` call, the EIP-3009 nonce MPP derives over the channel parameters and the salt, or the Permit2 witness. | A voucher or a top-up is within; `close` is the close. | Refuses `mpp/not-bound-within`. | none | no | | `mpp/session/tempo` | The `salt` of the signed `open` call to the channel escrow, in a transaction signed for the challenge's chain. On the v2 escrow the payload's descriptor carries the same salt and parties; on the v1 escrow the payload's `channelId` is the channel that transaction opens. [Checks on the Tempo opening](https://lcp.integraledger.com/guides/sessions.md#checks-on-the-tempo-opening) gives the checks and their order. | A voucher or a top-up is within; `close` is the close. | On the v2 escrow, the salt in the payment's channel descriptor, once the descriptor's channel id is the payment's channel and its operator is the challenge's `methodDetails.operator`, the zero address where the challenge names none, as on the opening. | none | yes | | `mpp/session/xrpl` | The `PaymentChannelCreate`'s one memo holding an LCP string, H's, in an opening the payer signs, single-signed or multisigned, that carries no `NetworkID`, as rippled requires on each network the challenge names, whose ids are at most 1024, else `xrpl/network-mismatch`, which `build`'s `complete` also gives. | A voucher is within; `close` is the close. | Refuses `mpp/not-bound-within`. | The opening's `CancelAfter`, where it sets one. | no | | `mpp/session/xrpl/stock` | None: the stock client opens the channel itself, out of band, with no memo, so the session is served only after an agreement on its own network is recorded (coverage `none`); an `open` credential is refused `mpp/session-action`, and `bound` refuses a voucher or close `mpp/no-signed-place`. | A voucher, which names the channel, is within; `close` is the close. | Refuses `mpp/not-bound-within`. | none | no | | `mpp/session/solana/memo` | One Memo instruction, H's LCP string, in the opening the payer signs and the seller's server submits, whose fee payer is the challenge's `operator`. | A voucher or a commit is within; `close` is the close. | Refuses `mpp/not-bound-within`. | none | no | | `mpp/session/solana/stock` | None: the buyer's client broadcasts the stock opening, which carries no H, so the session is served only after an agreement on its own network (coverage `none`); `bound` refuses `mpp/no-signed-place`. | Only the opening is classified; every later credential is `mpp/session-action`. | Refuses `mpp/not-bound-within`. | none | yes | | `mpp/session/hedera/stock` | None: the stock client opens the channel itself with a random salt, so the session is served only after an agreement on its own network (coverage `none`); `bound` refuses `mpp/no-signed-place`. | A voucher or a `topUp` is within; `close` is the close. | Refuses `mpp/not-bound-within`. | none | no | | `mpp/session/lightning` | The deposit invoice's description hash `h`, which the seller's node signs. | A bearer proof or a top-up is within; `close` is the close. | Refuses `mpp/not-bound-within`. | none | no | | `mpp/subscription/tempo` | The `witness` of the key authorization the payer's root key signs. | Only the activation, a key authorization, is classified: it is the opening. | Refuses `mpp/not-bound-within`. | The request's `subscriptionExpires`. | yes | | `mpp/subscription/solana` | The Memo instruction of the activation, H's LCP string (the request's `externalId`). | Only the activation, a `transaction` credential, is classified: it is the opening. Renewals are the seller's pulls. | Refuses `mpp/not-bound-within`. | The request's `subscriptionExpires`. | no | | `mpp/subscription/stripe` | The request's `methodDetails.metadata.legal_context`. | Every payment the seller reports on this pairing is the activation. | Refuses `mpp/not-bound-within`. | none | no | This example lists them from the registry: ```ts import { BINDINGS } from "@integraledger/lcp"; const channels = BINDINGS.filter((b) => "channel" in b).map((b) => b.id); console.log(channels.length); console.log(channels.sort().join("\n")); ``` ```text 13 mpp/session/evm mpp/session/hedera/stock mpp/session/lightning mpp/session/solana/memo mpp/session/solana/stock mpp/session/tempo mpp/session/xrpl mpp/session/xrpl/stock mpp/subscription/solana mpp/subscription/stripe mpp/subscription/tempo x402/batch-settlement/eip155 x402/batch-settlement/solana ``` Three x402 pairings carry a request-scoped form of the same idea, with no `channel` member: `x402/batch-settlement/cloudflare` echoes H in the `legalContext` extension of each request; `x402/upto/solana` opens a one-request payment channel whose opening transaction carries H as its memo; and on `x402/upto/xrpl` the payer opens a payment channel to the option's `payTo` itself, which carries no H, so the payment follows an agreement on the same network. The LCP profiles [`x402/batch-settlement/eip155`](https://lcp.integraledger.com/profiles/x402-batch-settlement-eip155.md), [`x402/batch-settlement/solana`](https://lcp.integraledger.com/profiles/x402-batch-settlement-solana.md), [`mpp/session/evm-tempo`](https://lcp.integraledger.com/profiles/mpp-session-evm-tempo.md), [`mpp/session/hedera-solana-xrpl`](https://lcp.integraledger.com/profiles/mpp-session-hedera-solana-xrpl.md), [`mpp/subscription/solana`](https://lcp.integraledger.com/profiles/mpp-subscription-solana.md) and [`mpp/subscription/stripe`](https://lcp.integraledger.com/profiles/mpp-subscription-stripe.md) state the rules for these bindings. ### Checks on the Tempo opening On the v1 escrow, `build`'s `tempo-call` funding carries two calls for the opening's transaction: `approve`, the currency's `approve(escrow, deposit)`, first, then `call`, the escrow's `open`, which takes the deposit with the currency's `transferFrom` and reverts without that allowance. On the v2 escrow, the TIP-20 channel reserve, the `open` takes the deposit without an allowance, and the funding carries `call` alone. On `mpp/session/tempo`, the opening transaction is signed for the challenge's chain, `methodDetails.chainId` (4217 where a v1 challenge names none), else `tempo/tx-malformed`. On the v2 escrow, the payload's descriptor carries the `open` call's salt and, as draft-tempo-session-00 requires, its payee, operator, token and authorizedSigner, the open transaction's sender, recovered from its signature, as its payer, and the expiring nonce hash of that transaction under that sender, else `tempo/descriptor-mismatch`. On the v1 escrow, the payload's `channelId` is the channel that transaction opens, computed from its sender and its `open` call, else `mpp/channel-not-bound`. The transaction is checked first, its `open` call and then its sender, as draft-tempo-session-00's open verification orders them, and with its sender its `aa_authorization_list`, each entry a list of four items ending in a signature that is not a keychain signature of type `0x03`, which Tempo's node refuses there as in the sender's. So an opening with a fault in its transaction and another in its channel id or descriptor is refused with the transaction's code. `build`'s `complete` returns no credential `bound` refuses: it gives the code `bound` gives the credential it would give for a transaction, which names the build's `from` (as the v2 descriptor's payer, and in the v1 `channelId`) and the `open` call `build` made. So it refuses each fault above, a sender other than `from`, a call naming other parties, and a transaction whose credential is over the credential size bound (`mpp/credential-malformed`); `voucher` refuses the same transactions. ### How the session pairings read the challenge An `mpp/session/xrpl` challenge's `amount` is the increment, in drops, charged for its request. `pairingsOf` takes only an opening challenge, whose `channelId` is absent or empty, and on it `build` signs that `amount` as the first claim's cumulative total, a big-endian u64. `pairingsOf`, and so `build`, `bound` and `reference`, refuses an `amount` that is not a u64 written in decimal with no sign, point or leading zero, or a `recipient` that is not a classic address whose checksum holds (the channel id derives from its AccountID), with `mpp/request-malformed`. Each session pairing's `bound` and `reference` hold the opening's echoed challenge to its filter, as the [MPP guide](https://lcp.integraledger.com/guides/mpp.md) says, and its `channel.ref`, given an opening, holds it as `bound` does, so an opening `bound` refuses for the credential's shape, the challenge's id, intent or method, or the filter is refused by `channel.ref` with the same code (the Stripe subscription's reads the activation receipt alone), and `channel.until` holds the opening as `channel.ref` does, giving no end for a payment `channel.kind` refuses or an opening whose echoed challenge `bound` refuses. Each MPP session pairing's `channel.ref` refuses a payment its `channel.kind` refuses, with that code, such as one whose action the pairing's draft does not define. Its `closeRef` holds the issued challenge it is given as `bound` holds an echoed one, so a fault in it gives `bound`'s code: the challenge's shape and its size in the least credential echoing it (`mpp/credential-malformed`), its `opaque` and `request`, its intent and method, and the filter. `closeRef` reads no id and no `legalContext`, which carry H: it takes the challenge as issued, before `place`, or as placed. A within or close payment's challenge, which the seller issues naming the channel, is read without the filter. ## The channel members On top of the members every pairing has, a channel pairing has: | Member | Side | What it does | |---|---|---| | `channel.kind(payment)` | seller | `"open"`, `"within"` or `"close"`, from the payment's own action or type, or a refusal. | | `channel.ref(payment)` | seller | The channel's key: `{ network, channel }`. The opening and every payment within share it. On the MPP sessions, a payment `channel.kind` refuses is refused with its code. | | `channel.boundWithin(payment)` | seller | H from a payment within the channel, where the pairing's payments within carry it; otherwise a refusal. | | `channel.until(payment)` | seller | The channel's end in Unix seconds, where its opening sets one; on the MPP sessions, none for a payment `channel.kind` refuses or an opening whose echoed challenge `bound` refuses. | | `buildWithin(within, h)` | buyer | A later voucher, or the close, for a channel opened under H. It refuses a channel that was not, except on `x402/batch-settlement/solana`, whose configuration does not carry H, and in the refund-authorizer mode of `x402/batch-settlement/eip155`, where it holds the channel salt to the option's refund authorizer instead. | | `closeRef(challenge, channel)` | seller | The read keys of the channel's close, on the MPP sessions on EVM, Tempo and the XRP Ledger, and on `mpp/subscription/tempo`, where a third argument names the payer's account. | `buildWithin` exists on the two x402 channels and the MPP sessions on EVM, Tempo and the XRP Ledger. On MPP it builds a voucher or the close. It does not build a top-up, which is a further deposit (`mpp/within-action-not-built`). An action the pairing's draft does not define, such as a `topUp` on the XRP Ledger, is `mpp/session-action`, as `channel.kind` answers it. On the XRP Ledger session the voucher and the close name the channel's payer, the opening's `Account`, by `source`, `did:pkh:xrpl:{network}:{address}`, as the opening's credential does: the stock server refuses a credential without it. On MPP, `buildWithin` reads the within challenge, the challenge of the seller's 402 within the channel, as the pairing's `channel.kind`, `channel.ref` and `channel.boundWithin` read the payment that carries it, with their code for each fault. It reads a snapshot of the challenge's own members, which the in-channel credential carries. A challenge that is not an object, is not challenge-shaped or has no string id, or whose least credential is over the credential size bound, is `mpp/credential-malformed`, and another intent or method `mpp/not-this-pairing`. Then come the request members the readers read: on the EVM and Tempo sessions its request, `sessionProtocol`, `chainId` and `escrowContract`, and on the XRP Ledger session its `methodDetails` and the network it names. The seller issues that challenge with its own id and the channel named, so it is not held to the pairing's filter, which refuses a challenge naming a channel. Where a reader refuses a payment whose within challenge names channel parameters other than the opening's, `buildWithin` gives that reader's code. On Tempo, a v2 within challenge whose escrow, chain or operator does not give the opening's channel, or one over a v1 opening, is `tempo/descriptor-mismatch`, and a v1 within challenge over a v2 opening is `mpp/not-bound-within`, as `channel.boundWithin` answers. The readers do not compare the network or escrow a within challenge names with the opening's on the EVM session, a Tempo v1 session or the XRP Ledger session, and neither does `buildWithin`. `buildWithin` checks its input in this order: the within challenge and the request members its readers read, H (`mpp/id-not-ours` for one that is not a valid ATR hash), the cumulative amount, the action, and only then the opening and its binding to H. The XRP Ledger session decodes its opening with `ripple-binary-codec`, so each check before the opening gives the same code with the codec and without it. `mpp/subscription/stripe`'s `channel.ref` takes the payment's receipt as a second argument: the Stripe subscription it names is the channel. ## One channel, end to end This program opens an x402 `batch-settlement` channel on an EVM chain, pays one voucher within it, and closes it. Both sides run in one process: a random key stands in for the buyer's signer and no network is used. Signing uses [viem](https://viem.sh). ```ts import { assemble, hashEquals, isRefusal, newAtrId } from "@integraledger/lcp"; import { requestCommitment, tie, type PaymentRequired, type PaymentRequirements } from "@integraledger/lcp/x402"; import { batchEvm, type SigningRequest } from "@integraledger/lcp/x402-batch-settlement"; import type { TypedDataDefinition } from "viem"; import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; const payer = privateKeyToAccount(generatePrivateKey()); async function sign(requests: readonly SigningRequest[]): Promise { const out: string[] = []; for (const r of requests) { if (r.kind !== "eip712") throw new Error(`this signer signs EIP-712 only, not ${r.kind}`); out.push(await payer.signTypedData(r.typedData as TypedDataDefinition)); } return out; } // Seller: the channel option. 1000 base units of USDC per request, on Base Sepolia. const option: PaymentRequirements = { scheme: "batch-settlement", network: "eip155:84532", amount: "1000", asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", payTo: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", maxTimeoutSeconds: 60, extra: { name: "USDC", version: "2", receiverAuthorizer: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", withdrawDelay: 900, }, }; const challenge: PaymentRequired = { x402Version: 2, resource: { url: "https://api.seller.example/v1/stream" }, accepts: [option], }; // Seller: one ATR for the whole channel, and H advertised in the challenge. const request = await requestCommitment({ method: "GET", target: "/v1/stream", body: new Uint8Array() }); if (isRefusal(request)) throw new Error(request.code); const terms = new TextEncoder().encode('{"text":"1000 base units of USDC per request."}'); const atr = await assemble(newAtrId(), tie(challenge.accepts, request), [["terms", terms]]); if (isRefusal(atr)) throw new Error(atr.code); const link = `https://atr.seller.example/${crypto.randomUUID()}`; const advertised = batchEvm.advertise(challenge, atr.atrHash, link, option); if (isRefusal(advertised)) throw new Error(advertised.code); // Buyer: read H, compare the served bytes with it as the buyer guide shows, then open the channel with H as its salt. const offer = batchEvm.read(advertised); if (isRefusal(offer)) throw new Error(offer.code); const accepted = offer.offer.options[0]!; const unsignedOpening = await batchEvm.build( { required: advertised, accepted, from: payer.address, payerAuthorizer: payer.address, deposit: 100_000n, authSalt: `0x${"01".repeat(32)}`, now: Math.floor(Date.now() / 1000), }, offer.h, ); if (isRefusal(unsignedOpening)) throw new Error(unsignedOpening.code); const kinds = unsignedOpening.requests.map((r) => (r.kind === "eip712" ? r.typedData.primaryType : r.kind)); console.log("the opening signs:", kinds); const opening = unsignedOpening.complete(await sign(unsignedOpening.requests)); if (isRefusal(opening)) throw new Error(opening.code); // Seller: the opening is bound to the H it issued, and names the channel. const h = await batchEvm.bound(opening); const channel = await batchEvm.channel.ref(opening); if (isRefusal(channel)) throw new Error(channel.code); console.log(batchEvm.channel.kind(opening), "bound to H:", typeof h === "string" && hashEquals(h, atr.atrHash)); // Buyer: a later voucher in the same channel, for a cumulative 2000 base units. const channelConfig = opening.payload["channelConfig"]!; const unsignedVoucher = await batchEvm.buildWithin( { required: advertised, accepted, channelConfig, maxClaimableAmount: 2000n }, offer.h, ); if (isRefusal(unsignedVoucher)) throw new Error(unsignedVoucher.code); const voucher = unsignedVoucher.complete(await sign(unsignedVoucher.requests)); if (isRefusal(voucher)) throw new Error(voucher.code); // Seller: the voucher is within the same channel, and its configuration still carries H. const sameChannel = await batchEvm.channel.ref(voucher); const within = await batchEvm.channel.boundWithin(voucher); const same = !isRefusal(sameChannel) && sameChannel.channel === channel.channel; console.log(batchEvm.channel.kind(voucher), "same channel:", same); console.log("within bound to H:", typeof within === "string" && hashEquals(within, atr.atrHash)); const notAnOpening = await batchEvm.bound(voucher); console.log("bound(voucher):", typeof notAnOpening === "string" ? notAnOpening : notAnOpening.code); // Buyer: the close, a full refund of what is left. const unsignedClose = await batchEvm.buildWithin( { required: advertised, accepted, channelConfig, maxClaimableAmount: 2000n, refund: {} }, offer.h, ); if (isRefusal(unsignedClose)) throw new Error(unsignedClose.code); const close = unsignedClose.complete(await sign(unsignedClose.requests)); if (isRefusal(close)) throw new Error(close.code); console.log(batchEvm.channel.kind(close)); ``` ```text the opening signs: [ 'ReceiveWithAuthorization', 'Voucher' ] open bound to H: true within same channel: true within bound to H: true bound(voucher): x402/not-an-opening close ``` Keep the opening exactly as the buyer signed it: every payment within the channel is built from its channel configuration, and `buildWithin` refuses a configuration whose salt is not H, or, in the refund-authorizer mode, whose salt does not end in the option's refund authorizer (`x402/channel-id-mismatch`). ## What each side keeps **The seller** refuses an opening whose H it did not issue for that request, or has already seen used. After that, it matches each later payment to an open channel by `channel.ref`, and so to that channel's ATR. What a voucher is worth, and when to settle, are the seller's to decide under the scheme. The channel members classify a payment and name its channel; none of them reads a voucher's amount. **The buyer** keeps the ATR's bytes it compared at the opening, and the opening itself. On MPP, a session challenge that names a `channelId` resumes a channel (`sessionResume` reads it on the MPP sessions on EVM, Tempo, Hedera and the XRP Ledger; a Solana session challenge names no channel, and `sessionResume` answers `null`): the buyer pays it with a voucher only for a channel it opened for an ATR it compared. ## What the record says Each channel pairing's `data.proves` states what the opening shows, and never that later requests or billing periods were paid under this ATR, which the record never reads. Where each voucher signs a value that commits to H, such as a `channelId` over the salt, it says so in one sentence, such as *"Each voucher in this channel signs a commitment to this ATR's hash."* The EVM and Tempo sessions and the EVM batch-settlement channel say so; on the XRP Ledger session, `data.proves` says that each voucher signs the channel id and an amount, not H. The [pairings reference](https://lcp.integraledger.com/reference/pairings.md#what-each-binding-proves) quotes each one. ## Reading settlement `reference(opening, option)` and `status(ref, reader, query)` read the opening's settlement, as on any pairing, and every answer is one of the closed list [the x402 guide](https://lcp.integraledger.com/guides/x402.md#reading-the-payment) gives. On the MPP sessions on EVM, Tempo and the XRP Ledger, and on `mpp/subscription/tempo`, `closeRef(challenge, channel)` gives the read keys of the close from the issued challenge and the channel, and `status` reads the close through the same reader. A failed result read above the reader's final mark is pending `below-mark`; at that mark, a failed answer comes only once the search is whole, on a pairing at coverage `full` ([Reading settlement](https://lcp.integraledger.com/guides/rails.md#reading-settlement)). On the EVM and Tempo sessions and the Tempo subscription, a named transaction that is not the act (an open call for another channel, a call that is not the close, a transaction sent through an ERC-4337 EntryPoint, a missing log) is no act, and with no search for H read whole the answer is pending `search-incomplete`. On `mpp/subscription/tempo`, the close is the account keychain's `KeyRevoked` naming the payer's account and the access key, so `closeRef(challenge, channel, account)` takes the account the activation registered the key for, which `keySearch` reads from the activation's receipt as `accessKey.account`; without it, `closeRef` refuses `mpp/input-malformed`. Another account's revocation of the same key is not this close. On `mpp/session/evm`, `mpp/session/tempo` and `mpp/subscription/tempo`, a reference that names none of the keys its own pairing writes for the opening or the close (`opens` or `closes` on the EVM session; `opened` or a binding log under `ChannelClosed` on the Tempo session; `revokes`, an `accessKey` with `account` or a binding log under `KeyAuthorizationWitness` on the subscription), or that names a key another of the three writes, is `unreadable`, `unparseable`, and nothing is read: no read could check H or the close. The `mpp/subscription/tempo` activation is read by what the payer signed in the key authorization: its `reference` names the `Transfer` of the authorization's one limit token, which is also its one allowed-call target, to its one recipient across its `transfer` and `transferWithMemo` rules, identified by the recipient alone, and `accessKey` carries the same token and recipient for `keySearch`. Tempo's subscription draft lets the key make only those calls and forbids `approve`, so no other rule names the recipient: an `approve` rule's spender is not one. The request's amount, currency and recipient are not read. An authorization that names more than one token or recipient, or none, is refused `tempo/key-authorization-malformed`. A `transfer` or `transferWithMemo` rule with no recipients allows any recipient, so the authorization does not name exactly one, and it is refused the same way. The key is the one the challenge issues, on the challenge's chain: Tempo's subscription draft requires the authorization of "the exact access key described by `methodDetails.accessKey`, including both `accessKeyAddress` and `keyType`", and a chain ID equal to `methodDetails.chainId`, so a key authorization whose key id, key type or chain id is another is refused `tempo/key-not-authorized` by `bound`, `reference` and `channel.ref`. The activation, the transfers `keySearch` finds under the key and the close `closeRef` names are read under that one key. On `x402/batch-settlement/eip155`, `bound` and `reference` read the opening's deposit amount as the channel contract's `deposit` takes it, a `uint128` that is not 0: an amount that is not a positive decimal below 2^128 is refused `x402/payload-malformed`. The reference's `amount` holds that amount. They read the deposit authorization's `validBefore` or `deadline` as the deposit collectors decode it, a `uint256`: one that is not a decimal below 2^256 is refused `x402/payload-malformed`, and the reference's `settleBy` is that value in decimal. The channel configuration that `bound`, `reference`, `channel.ref`, `channel.boundWithin` and `buildWithin` read is held to the rules that `deposit` applies: a configuration whose payer, receiver, receiver authorizer or token is the zero address, or whose withdrawal delay is outside 900 to 2,592,000 seconds, is refused `x402/payload-malformed`, and `build` refuses a payer, or an option's `payTo` or asset, that is the zero address with `x402/option-malformed`. A zero payer authorizer is read: the payer then signs the vouchers. `channel.kind` reads a refund's `amount`, when it is present, as the channel contract's `refund` takes it, a `uint128` that is not 0: one that is not a positive decimal below 2^128 is refused `x402/payload-malformed`. The opening's `status` settles on the deposit into the reference's channel in a transaction that consumed the deposit authorization's nonce (the token's `AuthorizationUsed(payer, nonce)` on ERC-3009, or the payer's Permit2 bit for the nonce set at its block and unset at the block before), where the channel's `receiver` is the option's payee. Any other deposit into the channel is a later payment of it, not the opening. The read defines no search for H: its search is never whole, and the answer is never `failed` but `before-position`. On `x402/batch-settlement/solana`, `bound`, `reference`, `channel.ref` and `buildWithin` read the channel configuration's `withdrawDelay` as the payment-channels program's `grace_period`, a `u32` that its `open` refuses as 0: a delay that is not a positive integer below 2^32 is refused `x402/payload-malformed`. They read its `payerAuthorizer` as the program's authorized signer, which `open` refuses off the Ed25519 curve: a key whose bytes are not a point on it, such as a program-derived address, is refused `x402/payload-malformed`, and `build` refuses one with `svm/input-malformed`. An `mpp/session/evm` opening is funded by an `authorization` (EIP-3009) or a `permit2`, which the seller's server sends; an opening of any other type is `mpp/credential-type`. Its reference carries `opens` (the escrow, the channel, H and the chain), the payer, the funding, and the payment as presented. `status` reads the opening by its funding, not by a named transaction: it reads the funding's single-use value at the final and the latest block, and searches the funding's own logs, the currency's `AuthorizationUsed` of the payer and the nonce, or the payer's `Transfer` to the escrow. An `authorization`'s nonce is a digest over the recipient and the token as well as H, and a `permit2` signs any unused nonce, so neither search is a search for H: it is never read whole, and the answer is never `failed` but `before-position`. A reference whose `opens` is not of that form is `unreadable`, `unparseable`, and nothing is read. ## Next - [x402](https://lcp.integraledger.com/guides/x402.md) and [MPP](https://lcp.integraledger.com/guides/mpp.md): the surfaces these channels run on. - [Buyer](https://lcp.integraledger.com/guides/buyer.md): the comparison the buyer makes before the opening. --- # Agentic checkouts > The ATR hash on ACP, UCP, AP2 and ACK checkouts, on card networks, and in A2A task metadata. Source: https://lcp.integraledger.com/guides/checkouts Updated 2026-11-20. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. Not every agent pays through a `402` challenge. Many buy through a checkout: the seller opens a checkout or a payment request, the buyer's agent completes it, and a payment service provider, a card network or a credential provider moves the money. This package places H in each of these checkouts in the field its protocol provides, delivers it in A2A task metadata, and says plainly where the buyer signs nothing. This page is for a seller or a buyer on one of these checkouts: it gives where H rides in each, the agreement every checkout sale makes first, and a program for each protocol. The members are the ones [every pairing has](https://lcp.integraledger.com/concepts/pairings.md#the-members). What differs is the document the seller advertises into and what the buyer presents: | Protocol | Entry point | Pairings | Where H rides | Buyer signs H | Confirmed | |---|---|---|---|---|---| | ACP | `@integraledger/lcp/acp` | `acp/checkout/delegated`, `acp/checkout/undelegated` | The checkout session's `id`, and the delegate-payment allowance's `checkout_session_id` where the handler requires one. | no | no | | UCP | `@integraledger/lcp/ucp` | `ucp/checkout/ap2-mandate`, `ucp/checkout/agent-signed`, `ucp/checkout/unsigned`, `ucp/booking/ap2-mandate`, `ucp/booking/unsigned` | A `legal_context` entry in the checkout's `links[]`, before the business signs the checkout; on `ucp/checkout/agent-signed` also the `legal_context` member of the platform's signed request that completes it. | with an AP2 mandate, or in the platform's signed request | no | | AP2 | `@integraledger/lcp/ap2` | `ap2/checkout-mandate`, `ap2/checkout-mandate/x402` | The `legalContext` member of the merchant-signed `checkout_jwt`, which the buyer's Checkout Mandate commits to; on the x402 route the payment's nonce carries the payment mandate chain, not H. | yes | no | | ACK | `@integraledger/lcp/ack` | `ack/payment-request` | The `id` of the seller-signed Payment Request, as H's LCP string. | no | no | | Card networks | `@integraledger/lcp/card` | `card/visa-tap`, `card/mastercard-agent-pay`, `card/visa-vic`, `card/mastercard-vi/immediate`, `card/mastercard-vi/autonomous`, `card/seller-reference` | The nonce or the checkout path the agent's message signature covers, the transaction reference of a Visa Intelligent Commerce credential request, the `checkout_jwt` a Verifiable Intent mandate signs, or the seller's processor reference. | Visa TAP, Agent Pay and Verifiable Intent | no | | A2A | `@integraledger/lcp/a2a` | none | The Task's `metadata`, under the extension's URI. Delivery only. | no | none | The "Buyer signs H" column says where each pairing's `data.carrier.signed` names a field. The [pairings reference](https://lcp.integraledger.com/reference/pairings.md#what-each-binding-proves) gives the sentence each pairing's record states about what a payment through it proves. No checkout pairing is confirmed yet (`data.confirmed` is `no` on every one): nothing outside this package has yet shown any of these forms as its profile defines it. The AP2, UCP, ACK and card pairings read each compact JWS and SD-JWT segment, each disclosure and each Verifiable Intent key coordinate as base64url without padding (RFC 7515 §2) in its canonical form only (RFC 4648 §3.5). One whose last character has a bit set past its last byte is malformed, and the pairing refuses it with the code it gives any other malformed one. Two compact JWSs are not decoded: a Key Binding JWT, which no pairing reads, and UCP's `ap2.merchant_authorization`, which the AP2 Mandate pairings match against UCP's schema pattern only. ## The agreement comes first Every pairing on this page has `data.coverage` `none`: no public ledger shows a payer-signed act carrying H. So every checkout sale is agreement-first. The seller passes an [agreement URL](https://lcp.integraledger.com/concepts/buyer-gate.md#the-agreement-url) to `advertise` as its last argument; `advertise` writes it where the protocol keeps the link, and `read` returns it as `agreement`. The buyer gate declines a checkout offer without one (`agreement-not-offered`). Unpaid, the agreement URL answers `402` with an x402 challenge that advertises the same H and link ([the seller guide](https://lcp.integraledger.com/guides/seller.md#the-agreement-url) gives the exchange). The buyer pays it first, as an agreement, with a payment that is itself a public proof of H, and completes the checkout only after the agreement's `200` receipt names the same H. Each pairing's sample below passes an agreement URL. ```ts import { agreementValue, hash, hashEquals, isRefusal } from "@integraledger/lcp"; import { delegated, type HandlerOption } from "@integraledger/lcp/acp"; import { exactEip3009, type PaymentRequired, type PaymentRequirements } from "@integraledger/lcp/x402"; import type { TypedDataDefinition } from "viem"; import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; const h = await hash(new TextEncoder().encode("the ATR's bytes")); const link = `https://atr.seller.example/${crypto.randomUUID()}`; const agreementUrl = `https://pay.seller.example/agreement/${crypto.randomUUID()}`; // Seller: the checkout names the agreement URL beside the link. const handler: HandlerOption = { requires_delegate_payment: true }; const session = delegated.advertise({ currency: "usd" }, h, link, handler, agreementUrl); if (isRefusal(session)) throw new Error(String(session.code)); // Seller: unpaid, the agreement URL answers 402 with an x402 challenge advertising the same H and link. const option: PaymentRequirements = { scheme: "exact", network: "eip155:84532", amount: "1", asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", payTo: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", maxTimeoutSeconds: 60, extra: { name: "USDC", version: "2" }, }; const unpaid: PaymentRequired = { x402Version: 2, resource: { url: agreementUrl }, accepts: [option] }; const challenge = exactEip3009.advertise(unpaid, h, link, option); if (isRefusal(challenge)) throw new Error(challenge.code); // Buyer: the checkout names an agreement URL, whose challenge advertises the same H. const offer = delegated.read(session); if (isRefusal(offer)) throw new Error(offer.code); const agreementOffer = exactEip3009.read(challenge); if (isRefusal(agreementOffer)) throw new Error(agreementOffer.code); console.log("agreement URL:", offer.agreement === agreementUrl, "same H:", hashEquals(agreementOffer.h, offer.h)); // Buyer: the agreement, built as one: its nonce is the agreement's own value, so the agreement and a charge never // share one. const payer = privateKeyToAccount(generatePrivateKey()); const unsigned = await exactEip3009.build( { required: challenge, accepted: option, from: payer.address, now: Math.floor(Date.now() / 1000) }, offer.h, "agreement", ); if (isRefusal(unsigned)) throw new Error(unsigned.code); console.log("nonce is agreementValue(H):", unsigned.typedData.message.nonce === (await agreementValue(offer.h))); const agreement = unsigned.complete(await payer.signTypedData(unsigned.typedData as TypedDataDefinition)); if (isRefusal(agreement)) throw new Error(agreement.code); // Seller of the agreement URL: the payment is this H's agreement. const bound = await exactEip3009.bound(agreement, { act: "agreement", h }); console.log("agreement bound to H:", typeof bound === "string" && hashEquals(bound, h)); ``` ```text agreement URL: true same H: true nonce is agreementValue(H): true agreement bound to H: true ``` ## ACP In the [Agentic Commerce Protocol](https://www.agenticcommerce.dev), the seller creates a checkout session and the buyer's agent completes it with a payment handler. These pairings target ACP 2026-04-17. This package makes H the session's `id`, and puts the link and the agreement URL beside it in the session's `metadata.legal_context`, in snake case: ```json no-check { "id": "0x1be27e75ea3728b55834ec54ff6709669427b11c9ba47a6d9f182b0be46513be", "metadata": { "legal_context": { "type": "sha256", "value": "0x1be27e75ea3728b55834ec54ff6709669427b11c9ba47a6d9f182b0be46513be", "legal_context_url": "https://atr.seller.example/2ff8f7af-0bd8-41fa-862e-cb0945fc149e", "legal_context_agreement_url": "https://pay.seller.example/agreement/5f0c2a5e-8d0e-4c1b-9d43-2a3c1f6b7e10" } } } ``` The ATR's binding slot, `tie(options)`, holds one option per kind of payment handler the session offers, each ACP's own `{ "requires_delegate_payment": boolean }`, and nothing from the checkout. The two pairings differ in that flag: - **`acp/checkout/delegated`**: the handler requires `delegate_payment`. `build` returns the allowance the agent's `delegate_payment` request carries: ACP's six members, with `reason` `"one_time"` and `checkout_session_id` set to H. The agent signs its request; `complete(request)` returns the request only when its allowance is exactly the one built, and refuses `acp/allowance-changed` otherwise. An allowance with no RFC 8785 form, such as one whose `merchant_id` holds an unpaired surrogate, is `acp/choice-malformed` at `build`, so the agent is never asked to sign a request `complete` would refuse. `bound` reads `checkout_session_id` back. It verifies no signature. - **`acp/checkout/undelegated`**: nothing the buyer signs names the session. `build` refuses `acp/nothing-to-sign` and `bound` refuses `acp/not-buyer-signed`. On `acp/checkout/undelegated`, `ucp/checkout/unsigned` and `card/seller-reference`, the payment is known from the seller's report alone. `reference({ charge }, option)` keys it by the processor's identifier of the charge, such as a Stripe PaymentIntent `id` or an Adyen `pspReference`, 1 to 255 visible ASCII characters (else `/charge-reference-malformed`), together with the checkout of the option it answers where the option names one (UCP and card). ```ts import { assemble, hash, hashEquals, isRefusal, newAtrId } from "@integraledger/lcp"; import { delegated, tie, type HandlerOption, type Session } from "@integraledger/lcp/acp"; // Seller: the session offers a handler that requires delegate_payment. const handler: HandlerOption = { requires_delegate_payment: true }; const terms = new TextEncoder().encode('{"line_items":[{"id":"li_1","quantity":1}],"total":19900}'); const atr = await assemble(newAtrId(), tie([handler]), [["order", terms]]); if (isRefusal(atr)) throw new Error(atr.code); const link = `https://atr.seller.example/${crypto.randomUUID()}`; const agreementUrl = `https://pay.seller.example/agreement/${crypto.randomUUID()}`; const opened: Session = { currency: "usd", metadata: { order_ref: "A-100" } }; const session = delegated.advertise(opened, atr.atrHash, link, handler, agreementUrl); if (isRefusal(session)) throw new Error(String(session.code)); console.log("session id is H:", session.id === atr.atrHash, Object.keys(session.metadata ?? {})); // Buyer: read H, the link and the agreement URL, fetch and compare, pay the agreement, then build the allowance. const offer = delegated.read(session); if (isRefusal(offer)) throw new Error(offer.code); console.log("agreement URL:", offer.agreement === agreementUrl); if (!hashEquals(await hash(atr.bytes), offer.h)) throw new Error("decline: hash-mismatch"); const unsigned = await delegated.build( { session, max_amount: 19900, currency: "usd", merchant_id: "acme", expires_at: "2026-10-01T00:00:00Z" }, offer.h, ); if (isRefusal(unsigned)) throw new Error(unsigned.code); const { checkout_session_id, ...rest } = unsigned.allowance; console.log("checkout_session_id is H:", checkout_session_id === offer.h, rest); // Buyer: the agent's own stack builds and signs its delegate_payment request around the allowance. // complete returns the request only when the allowance in it is the one built. const request = unsigned.complete({ allowance: unsigned.allowance, payment_method: { type: "card" } }); if (isRefusal(request)) throw new Error(String(request.code)); const changed = unsigned.complete({ allowance: { ...unsigned.allowance, max_amount: 99900 } }); console.log(isRefusal(changed) ? changed.code : "accepted"); // Buyer: confirm the request the agent signed carries H (the buyer gate's signed-not-bound check). // In ACP the seller never receives this request: `claims` is false, and the seller ties the payment to H in its report. const bound = await delegated.bound(request); console.log("bound to H:", typeof bound === "string" && hashEquals(bound, atr.atrHash)); ``` ```text session id is H: true [ 'order_ref', 'legal_context' ] agreement URL: true checkout_session_id is H: true { reason: 'one_time', max_amount: 19900, currency: 'usd', merchant_id: 'acme', expires_at: '2026-10-01T00:00:00Z' } acp/allowance-changed bound to H: true ``` `advertise` keeps every other member and metadata key, sets the session `id` only when it is absent or already H (`acp/id-conflict` otherwise), refuses a session that carries a `refused` member (`acp/session-malformed`), and refuses a session, given or as it would return it, larger than 1 MiB as JSON or nested more than 64 levels deep (`acp/too-large`). `read` takes H from `id` alone and refuses a `metadata.legal_context` whose value is another hash (`acp/legal-context-conflict`). Because H is the session's `id`, one session binds one ATR: a change to the terms the ATR records needs a new session, which the agent creates. The LCP profile [`acp/checkout/session-id`](https://lcp.integraledger.com/profiles/acp-checkout-session-id.md) states the rules. ## UCP In the [Universal Commerce Protocol](https://ucp.dev), the business returns a checkout, and, under UCP's AP2 Mandates extension, signs it (`ap2.merchant_authorization`). This package appends one entry to the checkout's `links[]` before the business signs it: ```json no-check { "type": "legal_context", "url": "https://atr.seller.example/…", "title": "lcp:sha256:0x…" } ``` and, with an agreement URL, a second entry of type `legal_context_agreement`. The option names the checkout or the booking by its own `id` (`{ "checkout": "…" }` or `{ "booking": "…" }`), and `tie(options)` records those ids. The booking pairings follow UCP's draft lodging booking capability, `dev.ucp.lodging.booking`, at commit [`c9a1395b`](https://github.com/Universal-Commerce-Protocol/ucp/tree/c9a1395b5db889dd201ddc982b9a020b3cbef9a7/docs/specification/lodging/booking). `advertise` refuses a checkout the business has already signed (`ucp/already-signed`), one whose `id` is not the option's (`ucp/option-not-this-checkout`) and one that carries a `refused` member (`ucp/checkout-malformed`). | Pairing | Buyer side | `bound` | |---|---|---| | `ucp/checkout/ap2-mandate`, `ucp/booking/ap2-mandate` | `read` requires the business's `ap2.merchant_authorization` (`ucp/ap2-not-active` otherwise). `build` returns the checkout unchanged for the buyer's mandate issuer, once its link carries H, and `complete(checkout_mandate)` gives what the buyer presents: the mandate and the checkout JWT its closed mandate discloses, so `bound` on it checks only that the two agree. | Reads the buyer's mandate, one SD-JWT or AP2's chain of the open and closed mandates joined by `~~`, checks AP2's `checkout_hash` against the presented `checkout_jwt`, and that any checkout the closed mandate discloses is that JWT, then reads H from that checkout's `legal_context` link. It verifies no signature, no `cnf` delegation and no link between the chained mandates. UCP's AP2 Mandates extension has the business verify the checkout mandate's signatures, key binding and expiry itself; `bound` does not, so run that verification before relying on its result. For AP2's latest-checkout check, build `checkout_jwt` from your own `ap2.merchant_authorization` for the checkout's current state, with its payload attached, not from the mandate: `bound` then refuses `ap2/checkout-not-latest` when the mandate commits to another state of the checkout. | | `ucp/checkout/agent-signed` | `read` gives H and the link. `build(offer, h)` returns `{ legal_context: { type: "sha256", value: H } }` once the checkout's link carries H (else `ucp/hash-not-in-checkout`), which the platform writes into the body of the request that completes the checkout; the platform's RFC 9421 signature covers that body through `content-digest`. | Takes `{ body, contentDigest }` as the business received them. Requires `contentDigest` to be exactly `sha-256=:`, the standard base64 of SHA-256 over the body, and `:` (`ucp/content-digest-mismatch`), then reads H from the body's one `legal_context` member. It verifies no signature and reads no key, so verify the platform's signature first. The LCP profile [`ucp/checkout/agent-signed`](https://lcp.integraledger.com/profiles/ucp-checkout-agent-signed.md) states the rules. | | `ucp/checkout/unsigned`, `ucp/booking/unsigned` | `read` gives H and the link. `build` refuses `ucp/nothing-to-sign`: UCP without the AP2 Mandates extension defines no buyer signature. | Refuses `ucp/not-buyer-signed`. On `ucp/checkout/unsigned`, `reference({ charge }, option)` keys the payment by the processor's charge id, as on [ACP](https://lcp.integraledger.com/guides/checkouts.md#acp). | `legalContextLink(checkout)` reads the one `legal_context` entry of any checkout: two such entries are `ucp/legal-context-conflict`. The LCP profile [`ucp/checkout/legal-context`](https://lcp.integraledger.com/profiles/ucp-checkout-legal-context.md) states the rules. ```ts import { hash, isRefusal } from "@integraledger/lcp"; import { legalContextLink, unsigned, type Checkout } from "@integraledger/lcp/ucp"; const h = await hash(new TextEncoder().encode("the ATR's bytes")); const link = "https://atr.seller.example/2ff8f7af-0bd8-41fa-862e-cb0945fc149e"; const agreementUrl = "https://pay.seller.example/agreement/5f0c2a5e-8d0e-4c1b-9d43-2a3c1f6b7e10"; const checkout: Checkout = { id: "chk_123", status: "ready_for_complete", links: [{ type: "terms_of_service", url: "https://seller.example/tos" }], }; const placed = unsigned.advertise(checkout, h, link, { checkout: "chk_123" }, agreementUrl); if (isRefusal(placed)) throw new Error(String(placed.code)); console.log(placed.links); const found = legalContextLink(placed); console.log(isRefusal(found) ? found.code : found.h === h); const offer = unsigned.read(placed); console.log(isRefusal(offer) ? offer.code : offer.agreement === agreementUrl); const wrong = unsigned.advertise(checkout, h, link, { checkout: "chk_999" }, agreementUrl); console.log(isRefusal(wrong) ? wrong.code : "placed"); console.log(isRefusal(await unsigned.build({ checkout: placed }, h))); ``` ```text [ { type: 'terms_of_service', url: 'https://seller.example/tos' }, { type: 'legal_context', url: 'https://atr.seller.example/2ff8f7af-0bd8-41fa-862e-cb0945fc149e', title: 'lcp:sha256:0x3283f4fc90a2f6d2782b0345c3b274acbe0218ec84ce2d8c3a1fdbe6d1cff263' }, { type: 'legal_context_agreement', url: 'https://pay.seller.example/agreement/5f0c2a5e-8d0e-4c1b-9d43-2a3c1f6b7e10' } ] true true ucp/option-not-this-checkout true ``` A UCP checkout paid in x402 goes through the payment handler `com.integraledger.lcp.x402`. Its `config` in the checkout is the x402 `PaymentRequired` that carries H. Its credential is the buyer's signed x402 payment. Without AP2 mandates, the payment carries H where the option's x402 pairing places it, and the checkout's ATR takes that pairing's binding slot, whose request is the checkout's completion, so the ATR names the checkout. Under UCP's AP2 Mandates extension the checkout mandate binds H, and the handler's [Under AP2 mandates](https://lcp.integraledger.com/profiles/ucp-payment-handler-x402.md#under-ap2-mandates) rules apply in place of these; [AP2](https://lcp.integraledger.com/guides/checkouts.md#ap2) covers the checkout mandate. The LCP profile [`ucp/payment-handler/x402`](https://lcp.integraledger.com/profiles/ucp-payment-handler-x402.md) is the handler's specification, and [`ucp-payment-handler-x402.schema.json`](https://github.com/IntegraLedger/integra-protocol/blob/main/lcp/profiles/ucp-payment-handler-x402.schema.json) its schema. Their addresses are `https://lcp.integraledger.com/ucp/x402/2026-10-02` and `https://lcp.integraledger.com/ucp/x402/2026-10-02/schema.json`. ## AP2 In [AP2](https://ap2-protocol.org), the merchant signs a `checkout_jwt` and the buyer's closed Checkout Mandate commits to it through `checkout_hash`, the SHA-256 of that JWT. AP2 lets the mandate's `_sd_alg` choose that hash; this package reads a mandate whose `_sd_alg` is `sha-256` or absent, and refuses one with any other value (`ap2/sd-alg-unsupported`). The pairing targets AP2 v0.2 (Checkout Mandates, `mandate.checkout.1`). This package puts H in the JWT's payload: - **Seller.** `advertise(payload, h, link, { checkout: id }, agreementUrl)` appends a `legalContext` member, `{"type":"sha256","value":H,"legalContextUrl":link,"legalContextAgreementUrl":agreementUrl}`, to the checkout payload whose `id` is the option's, and refuses a payload that carries a `refused` member (`ap2/jws-malformed`). The seller's own stack signs the result as its `checkout_jwt`. - **Buyer.** `read(checkoutJwt)` decodes the JWT's payload and returns H, the link and the checkout. `build(offer, h)` returns the Checkout Mandate's required claims: `vct` `"mandate.checkout.1"`, the `checkout_jwt`, and `checkout_hash`, the unpadded base64url of SHA-256 over the JWT. The buyer's mandate signer issues the mandate as an SD-JWT, and `complete(checkout_mandate)` gives what the buyer presents: the mandate and the JWT. - **Seller, on payment.** `bound(presented)` takes the mandate as presented: one SD-JWT or, when the agent pays under the user's open mandate, AP2's chain of the open mandate's SD-JWT and the closed mandate's, joined by `~~`. A chain has at most these two hops, and each must read as an SD-JWT. `bound` finds the one closed Checkout Mandate in the last SD-JWT, checks that its `checkout_hash` is the hash of the presented `checkout_jwt` (`ap2/checkout-not-latest` otherwise), and reads H from that JWT's payload. It verifies no signature, no `cnf` delegation and no `sd_hash` or `issuer_jwt_hash` link between the hops, and does not evaluate the open mandate's constraints. AP2 has the merchant verify the Checkout Mandate, and `bound` does not, so before relying on its result your AP2 stack verifies the chain: the first SD-JWT with the issuer's key, the closed mandate with the key the open mandate delegates to in `cnf`, its `sd_hash` or `issuer_jwt_hash`, and the open mandate's constraints. AP2 has the merchant check that `checkout_hash` matches the latest `checkout_jwt`. For that check, build `presented` from the mandate and the `checkout_jwt` you last sent for that checkout, not the buyer's copy: `bound` then refuses `ap2/checkout-not-latest` when they differ. With the buyer's copy, it checks only that the mandate and that JWT agree. `jwsPayload`, `readMandate` and `checkoutBinding` expose those steps one by one. The LCP profile [`ap2/checkout-mandate`](https://lcp.integraledger.com/profiles/ap2-checkout-mandate.md) states the rules. **On the x402 route** (`ap2/checkout-mandate/x402`), AP2's x402 credential provider writes the EIP-3009 authorization's nonce as keccak-256 of the payment mandate chain, so the payment itself carries no H. H rides in the `checkout_jwt` that the closed mandate commits to, as above. `bound` takes `{ checkout_mandate, checkout_jwt, payment }`, `payment` being AP2's x402 bundle as the merchant receives it, and reads H from the mandate and the JWT. It refuses `ap2/payment-not-bound` where the authorization's nonce is not keccak-256 of the bundle's `payment_mandate_chain`, or where the chain's closed Payment Mandate does not name this checkout. `reference(presented, method)`, against the checkout's x402 method `{ type: "x402", address, network, asset }`, and `status` read the carried EIP-3009 payment as `x402/exact/eip155/eip3009` does, at coverage `none`, with the authorization's own nonce where that pairing has H. AP2 writes the method's `network` as an x402 v1 network name (`base-sepolia`); `x402MethodNetwork(network)` gives its CAIP-2 id (`eip155:84532`) by `@x402/evm`'s v1 table, as `reference` reads it, or an `eip155` CAIP-2 id as given. The LCP profile [`ap2/checkout-mandate/x402`](https://lcp.integraledger.com/profiles/ap2-checkout-mandate-x402.md) states the rules. ```ts import { hash, isRefusal } from "@integraledger/lcp"; import { checkoutMandate } from "@integraledger/lcp/ap2"; const h = await hash(new TextEncoder().encode("the ATR's bytes")); const checkout = { id: "chk_42", total: { currency: "USD", value: "19.90" } }; const link = `https://atr.seller.example/${crypto.randomUUID()}`; const agreementUrl = `https://pay.seller.example/agreement/${crypto.randomUUID()}`; const payload = checkoutMandate.advertise(checkout, h, link, { checkout: "chk_42" }, agreementUrl); if (isRefusal(payload)) throw new Error(String(payload.code)); console.log(Object.keys(payload)); // The seller's stack signs the payload. A placeholder signature stands in: the buyer's side verifies none. const segment = (v: object) => Buffer.from(JSON.stringify(v)).toString("base64url"); const signature = Buffer.from("signature").toString("base64url"); const checkoutJwt = `${segment({ alg: "ES256", typ: "JWT" })}.${segment(payload)}.${signature}`; const offer = checkoutMandate.read(checkoutJwt); if (isRefusal(offer)) throw new Error(offer.code); console.log("agreement URL:", offer.agreement === agreementUrl); const unsigned = await checkoutMandate.build(offer.offer, offer.h); if (isRefusal(unsigned)) throw new Error(unsigned.code); console.log(unsigned.content.vct, unsigned.content.checkout_hash.length); ``` ```text [ 'id', 'total', 'legalContext' ] agreement URL: true mandate.checkout.1 43 ``` ## ACK In the payment flow of the [Agent Commerce Kit (ACK)](https://www.agentcommercekit.com), the seller answers with a `402` whose body carries a signed Payment Request token, and a receipt issued after settlement embeds that token. The pairing targets ACK protocol version 2025-05-04. This package makes H the Payment Request's `id`, in LCP string form, and puts the link beside the request in the `402` body: - **Seller.** `advertise({}, h, link, option, agreementUrl)` returns the values the seller's stack places: `paymentRequestId`, `lcp:sha256:0x…`, for the token it signs, and `legalContext`, `{type, value, legalContextUrl, legalContextAgreementUrl}`, for the body beside it. `tie(options)` records the Payment Request's options exactly as issued. - **Buyer.** `read(body)` takes H from the signed token's `id`, which must equal the body's `legalContext` (`ack/legal-context-conflict` otherwise), and returns the token's payment options. The body's unsigned `paymentRequest` copy is never read. The token's signature is not verified here. - **After settlement.** `fromReceipt(credentialSubject)` reads H from the Payment Request token a receipt embeds. It verifies nothing: call it on a receipt you have verified. ACK defines no payer signature, so there is no place for H in what the buyer signs. `build` and `bound` refuse `ack/no-signed-place`. The LCP profile [`ack/payment-request`](https://lcp.integraledger.com/profiles/ack-payment-request.md) states the rules. ## Card networks The `card` entry point covers five ways to pay a card checkout. The option is the seller's own `{ scheme, checkout }`, where `scheme` is `"visa-tap"`, `"mastercard-agent-pay"`, `"visa-vic"`, `"mastercard-vi"` or `"seller-reference"` and `checkout` is the seller's checkout id. `advertise` gives the same values for every card pairing: the `legalContext` the seller shows before payment, with the agreement URL after the link, and `reference`, H's LCP string, for the seller to place in its processor reference. - **[Visa Trusted Agent Protocol](https://developer.visa.com/capabilities/trusted-agent-protocol).** H rides in what the agent's `agent-payer-auth` message signature covers (RFC 9421): its `nonce`, the base64 of H's 32 bytes followed by 32 random bytes, which `build` returns as `{ nonce }` for the agent's signer to place in every signature of the request; or, for an agent whose nonce does not carry H, the merchant's checkout path, whose last segment is H and which the signature covers as `@path`. `bound` takes the request's `signatureInput`, `signature` and, for the path, its `path`, and returns H when every `agent-payer-auth` signature carries the same H. It reads the key id parameter as `keyid` and as `keyId`, the spelling Visa's reference agent writes. It verifies no signature, key, window or nonce. The LCP profile [`card/visa-tap`](https://lcp.integraledger.com/profiles/card-visa-tap.md) states the rules. - **Mastercard Agent Pay.** TAP's carrier, in a message signature whose `tag` is `Agent-pay-auth` or `agent-pay-auth`, the two spellings Mastercard publishes. The form is built from Mastercard's published playbook and is not confirmed: the LCP profile [`card/mastercard-agent-pay`](https://lcp.integraledger.com/profiles/card-mastercard-agent-pay.md) states it. - **Visa Intelligent Commerce.** H, as unpadded base64url, is the `transactionReferenceId` the agent writes when it asks Visa for the sale's credential; `build` returns it, and `bound` reads it back as the merchant reads it from the credential payload Visa signs. That Visa returns it unchanged is not yet shown, so the form is not confirmed: the LCP profile [`card/visa-vic`](https://lcp.integraledger.com/profiles/card-visa-vic.md) states it. - **[Mastercard Verifiable Intent](https://github.com/agent-intent/verifiable-intent).** The pairings target Verifiable Intent at commit `356c296`. H rides in the `checkout_jwt` as its `legalContext`, and a mandate signs that JWT's SHA-256 as `checkout_hash`. `build` returns `checkoutMandate`, the checkout mandate to sign, and `transactionId`, the value for the payment mandate's `transaction_id`: both carry that digest. In Immediate mode the agent may create the `checkout_jwt`: `read` then takes the `legalContext` the seller shows, and `build`, given `{ checkout, shown }`, returns the checkout payload with that `legalContext` written into it, for the agent to sign. `card/mastercard-vi/immediate` reads H from the checkout mandate the user's L2 mandate references, and checks the `checkout_hash` and any disclosed `transaction_id`; it verifies no signature. `card/mastercard-vi/autonomous` reads H from the agent's L3b checkout mandate, and verifies the ES256 signatures of L2 and L3b and their `sd_hash` links, but not the L1 issuer's signature; its `l2` is the merchant's view of the user's L2 that L3b's `sd_hash` covers. The LCP profile [`card/mastercard-vi`](https://lcp.integraledger.com/profiles/card-mastercard-vi.md) states the rules. - **`card/seller-reference`.** A plain card checkout: nothing the buyer signs carries H. The seller shows H and the link before payment and places `reference` in its processor reference. `build` and `bound` refuse `card/no-signed-place`, and `reference({ charge }, option)` keys the payment by the processor's charge id, as on [ACP](https://lcp.integraledger.com/guides/checkouts.md#acp). ```ts import { hash, isRefusal } from "@integraledger/lcp"; import { visaTap, type CardOption } from "@integraledger/lcp/card"; const h = await hash(new TextEncoder().encode("the ATR's bytes")); const option: CardOption = { scheme: "visa-tap", checkout: "order-7731" }; const link = `https://atr.seller.example/${crypto.randomUUID()}`; const agreementUrl = `https://pay.seller.example/agreement/${crypto.randomUUID()}`; const shown = visaTap.advertise({}, h, link, option, agreementUrl); if (isRefusal(shown)) throw new Error(shown.code); console.log(shown.reference === `lcp:sha256:${h}`); const offer = visaTap.read(shown); console.log(isRefusal(offer) ? offer.code : offer.agreement === agreementUrl); const placed = await visaTap.build(shown, h); if (isRefusal(placed)) throw new Error(placed.code); const bytes = Uint8Array.from(atob(placed.nonce), (c) => c.charCodeAt(0)); console.log(placed.nonce.length, `0x${Buffer.from(bytes.subarray(0, 32)).toString("hex")}` === h); ``` ```text true true 88 true ``` ## A2A The [Agent2Agent protocol](https://a2a-protocol.org) signs nothing per transaction, so it has no place for H in a payment. What it can do is deliver H and the link with the task. This package defines an A2A extension for that, and exports no pairing: `binding` is the refusal `a2a/no-signed-place`, and the payment made for the task uses its own pairing, whose record states what it proves. The extension targets A2A 1.0. When the task carries an x402 payment under the a2a-x402 extension, H and the link ride in the embedded x402 challenge's `extensions.legalContext`, as in any x402 challenge: the x402 pairing's `read` reads them there, and `read` here, which reads only the Task's `metadata` under this extension's URI, does not. | Export | What it does | |---|---| | `A2A_EXTENSION_URIS` | The extension's URI: `https://lcp.integraledger.com/a2a/legal-context/v1`. | | `agentExtension({ required? })` | The Agent Card `capabilities.extensions[]` entry that declares it. Leave `required` false: A2A asks agents not to mark data-only extensions as required. | | `requested(header)` | Whether a request's `A2A-Extensions` header value, at most 8,192 characters with at most 64 elements, names the extension. | | `place(task, h, link, header?)` | A copy of the Task with `{type, value, legalContextUrl}` in its `metadata`, under the extension's URI. Other metadata is kept. A Task that carries a `refused` member is `a2a/legal-context-malformed`. | | `read(task)` | H and the link from the Task's `metadata`. | | `delivery.proves` | What the delivery shows: nothing about the payment. | ```ts import { hash, isRefusal } from "@integraledger/lcp"; import { agentExtension, place, read, requested, type A2aTask } from "@integraledger/lcp/a2a"; console.log(agentExtension()[0]?.uri); const h = await hash(new TextEncoder().encode("the ATR's bytes")); const header = "https://lcp.integraledger.com/a2a/legal-context/v1"; console.log(requested(header)); const task: A2aTask = { id: "task-1", contextId: "ctx-1", status: { state: "TASK_STATE_INPUT_REQUIRED" } }; const link = `https://atr.seller.example/${crypto.randomUUID()}`; const delivered = place(task, h, link, header); if (isRefusal(delivered)) throw new Error(String(delivered.code)); const got = read(delivered); console.log(isRefusal(got) ? got.code : got.h === h && got.link === link); console.log(read(task)); ``` ```text https://lcp.integraledger.com/a2a/legal-context/v1 true true { refused: true, code: 'a2a/no-legal-context' } ``` The LCP profile [`a2a-legal-context-v1`](https://lcp.integraledger.com/profiles/a2a-legal-context-v1.md) states the extension's rules. ## Next - [Buyer](https://lcp.integraledger.com/guides/buyer.md): the gate every checkout on this page runs before the buyer approves. - [Pairings reference](https://lcp.integraledger.com/reference/pairings.md): each checkout pairing's pattern and what its record proves. --- # Rails > Where the ATR hash rides on each chain and on Lightning, and how each rail's settlement is read. Source: https://lcp.integraledger.com/guides/rails Updated 2026-11-20. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. A **rail** is where the payment settles: an EVM chain, Solana, the XRP Ledger, a Lightning node. x402 and MPP each define how a payment is authorized on a rail, and each rail offers different fields a payment can carry: a nonce, a memo, a note, a salt, an invoice field. This page gives, for every rail the package's x402 and MPP pairings use, the field H rides in, the pairings that use it, and how the settlement is read. It is for a seller or settler that reads a payment on chain: at the end you know what each rail carries and what your reader must answer. The checkout pairings are in [Agentic checkouts](https://lcp.integraledger.com/guides/checkouts.md). Each rail's pieces are in their own entry point, such as `@integraledger/lcp/evm` or `@integraledger/lcp/sui`: the signed form the payer produces, where H sits in it, and the settlement read. The pairings that use a rail are exported from the protocol's entry point or the rail's own, as the [pairings reference](https://lcp.integraledger.com/reference/pairings.md) lists. The package reads each standard base64 text on a rail as padded standard base64 (RFC 4648 §4) in its canonical form only (RFC 4648 §3.5): what the payer signs (a Sui, Cardano, Aptos, Algorand, Hedera, Solana, Stellar or Stacks transaction, a NEAR signed delegate action, a TON message), a TON option's forward payload and the TON state init `build` takes, and what a node answers (an Algorand genesis hash, a Hedera Mirror Node memo, NEAR function-call arguments, Stellar event topics and values). A text whose last character before the padding has a bit set past the last byte spells the same bytes in another form, and each reader answers it as it answers any other malformed text. Each byte array the package returns is a `Uint8Array` that shares no memory with any input: the bytes `assemble` writes, `toRawBytes` and the base64 readers, each rail's decoded fields, and the bytes each `build` hands the payer's signer. It passes as a `BlobPart` or a `BufferSource` (to `Blob`, `Response`, `crypto.subtle` or `TextDecoder`) as it is. The one exception is the TON cell `lcpComment` gives: it is `@ton/core`'s own `Cell`, whose `hash()` answers a Node `Buffer`. Each function that reads bytes takes any `Uint8Array`, a Node `Buffer` included. A decoded type that a function also reads (`Bolt11`, `ProfileCall`, `SuiTx`, `SvmTx`, `TronRaw`) takes its bytes' backing as a type parameter: `ArrayBuffer` where the package decoded it, any backing where a function reads it. ## The forms H takes on a rail A rail field holds H in one of these forms: | Form | Size | Used where | |---|---|---| | H's 32 bytes | 32 bytes | EVM nonces and salts (the Circle Gateway batched authorization's nonce among them), the Tempo `transferWithMemo` memo, the Casper nonce, Sui's unused `Pure` input, the Stacks memo, the MPP XRPL `InvoiceID`, the Lightning invoice's description hash `h`. | | H's LCP string, `lcp:sha256:0x…` | 77 bytes | Memos and notes: Solana, Algorand, Hedera, NEAR, Tron, TON, Concordium, the Polkadot remark, Cardano's CIP-20 message, the XRPL session memo. | | H's low 250 bits | one felt | The Starknet nonce. | | SHA-256 of H's LCP string | 32 bytes | The x402 XRPL `InvoiceID`. | | H's 32 bytes, then the signer's 8-byte nonce | 40 bytes | The Stellar signed-payload precondition (CAP-40): the buyer's Soroban authorization entry's `nonce`, an XDR `int64`. | | A value derived from the challenge id | varies | The MPP `authorization` and `permit2` charges on EVM, and `usdc` on EVM and Gateway, whose nonce, salt or memo derives from the challenge id that carries H. | The 77 bytes of H's LCP string are the string itself. Concordium writes it as a CBOR text string of 79 bytes, 83 inside a PLT transfer's CBOR tag 24, and Cardano's CIP-20 message holds it as two strings of 13 and 64 bytes, since a CIP-20 string holds at most 64 bytes. A field that holds a value derived from H, such as a digest over a preimage that holds it, lets anyone holding the ATR confirm H, but does not let anyone recover H from the chain alone. Each pairing's `pattern` says which it is: `zeroPartyRecoverable` is true only where the chain keeps H itself. No pairing takes part of H as proof: a field too small for H carries none of it. This example prints the forms for one H, using each rail's own helper: ```ts import { hash, toLcpString } from "@integraledger/lcp"; import { challengeId } from "@integraledger/lcp/mpp"; import { snNonce } from "@integraledger/lcp/starknet"; import { mppInvoiceId, x402InvoiceId } from "@integraledger/lcp/xrpl"; const h = await hash(new TextEncoder().encode("abc")); console.log("H: ", h); console.log("LCP string (memos): ", toLcpString(h)); console.log("Starknet nonce: ", snNonce(h)); console.log("x402 XRPL InvoiceID: ", await x402InvoiceId(h)); console.log("MPP XRPL InvoiceID: ", mppInvoiceId(h)); console.log("MPP challenge id: ", challengeId(h, 0)); ``` ```text H: 0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad LCP string (memos): lcp:sha256:0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad Starknet nonce: 0x27816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad x402 XRPL InvoiceID: FD9AF578DE2AF5DFC44BE5821EEF4EFE048BB2268AC8F59D58162E8310A3AB73 MPP XRPL InvoiceID: BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD MPP challenge id: ungWv48Bz-pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0.0 ``` ## Rail by rail | Rail | Entry point | Pairings | Where H rides | |---|---|---|---| | EVM chains (`eip155`) | `evm` | `x402/exact/eip155/eip3009`, `x402/exact/eip155/permit2`, `x402/upto/eip155/permit2` | The nonce of the EIP-3009 authorization, or of the Permit2 witness transfer, the payer signs. | | | | `x402/auth-capture/eip155/eip3009`, `x402/auth-capture/eip155/permit2` | The escrow payment's salt, or a commitment over it with the receiver authorizer and policy, which the token authorization's nonce commits to. | | | | `x402/exact/eip155/erc7710-salt`, `x402/exact/eip155/erc7710` | The salt of the redeemed leaf delegation; or, where the delegation signs no hash, the echoed extension only. | | | | `x402/batch-settlement/eip155`, `mpp/session/evm` | The channel's salt. See [Channels, sessions and subscriptions](https://lcp.integraledger.com/guides/sessions.md). | | | | `mpp/charge/evm/authorization`, `mpp/charge/evm/permit2`, `mpp/charge/usdc/evm`, `mpp/charge/usdc/gateway` | A nonce or salt derived from the MPP challenge id. | | | | `mpp/charge/evm/transaction`, `mpp/charge/evm/hash` | The challenge only; the payment transaction carries nothing. | | | `x402` | `x402/exact/eip155/gateway-batched` | The nonce of the Circle Gateway batched authorization the payer signs: H. Circle settles it in batches, and no public ledger shows it. | | Tempo | `tempo` | `mpp/session/tempo`, `mpp/subscription/tempo` | The channel's salt, or the key authorization's witness. | | | `mpp` | `mpp/charge/tempo/split-memo`, `mpp/charge/tempo/split-memo/push` | The memo of one `transferWithMemo` call in the payer's signed Tempo transaction: H's 32 bytes, which the challenge places as one split's memo. | | Solana | `svm`, `x402-exact-solana`, `x402-upto-solana` | `x402/exact/solana`, `x402/upto/solana`, `x402/batch-settlement/solana`, `mpp/charge/solana`, `mpp/charge/solana/unsponsored`, `mpp/charge/usdc/solana`, `mpp/session/solana/memo`, `mpp/subscription/solana` | The one Memo instruction holding H's LCP string; on the MPP charges, Memo instructions whose data is not an LCP string are not read. An `x402/batch-settlement/solana` opening also carries x402's receiver-authorizer binding memo. On `mpp/session/solana/memo` the memo is in the channel's `open`, and on `mpp/subscription/solana` in the activation. | | | | `mpp/session/solana/stock` | Nothing: the opening carries no H. An agreement transaction carrying H precedes it. | | XRP Ledger | `xrpl`, `x402-exact-xrpl`, `x402-upto-xrpl` | `x402/exact/xrpl` | The Payment's `InvoiceID`: SHA-256 of H's LCP string. The blob is single-signed or multisigned: the payment is found by the payer's `Account` and signed `Sequence` or ticket, so a copy signed by another quorum, under another hash, is the same payment. The blob carries `NetworkID` as rippled requires of the option's network, none where its id is at most 1024 and that id above 1024, else `xrpl/network-mismatch`, which `build`'s `complete` also gives. | | | | `mpp/charge/xrpl` | The Payment's `InvoiceID`: H. The payer signs with a single key, as for `x402/exact/xrpl`. | | | | `mpp/session/xrpl` | The `PaymentChannelCreate`'s one memo holding an LCP string: H's. The payer signs the opening with a single key. | | | | `x402/upto/xrpl` | Nothing: the payer opens a payment channel itself, after an agreement on the same network, and presents the channel and its account; the read finds the channel's create. | | | | `mpp/session/xrpl/stock` | Nothing: the channel's create carries no H. An agreement transaction carrying H precedes it. | | Hedera | `hedera` | `x402/exact/hedera` | The signed transaction body's memo: H's LCP string. | | | `mpp` | `mpp/charge/lcp/hedera` | The memo of the payer's signed crypto transfer: H's LCP string. | | | `hedera` | `x402/exact/hedera/transfer-executor` | The challenge only. | | | `mpp` | `mpp/session/hedera/stock` | Nothing: the opening carries no H. An agreement transaction carrying H precedes it. | | Algorand | `avm` | `x402/exact/algorand` | The asset transfer's `note`: H's LCP string. The payment entry is read as the x402 facilitator decodes it and as algod decodes the bytes the facilitator submits: an entry either reader refuses, or that the two read as different signed transactions, is `avm/txn-malformed`, and the transaction id is the one algod computes, from the transaction's canonical encoding. The facilitator decodes an entry's base64 with Node's `Buffer.from(entry, "base64")`, which takes other spellings of the same bytes; `avmCarrier` reads the canonical form only (RFC 4648 §3.5). | | Aptos | `aptos` | `x402/exact/aptos` | The challenge only. No field of a standard Aptos transfer carries H; the seller ties the payment to H when it claims it for the request. `build`'s `complete` reads the signed transaction as `reference` reads it and gives `reference`'s code for each fault: a `transaction` that is not a string is `x402/payload-malformed`; text that is not base64 of a transaction prefix that reads to the end of its fields, or that names a module, function or struct with a name that is not a Move identifier, is `aptos/tx-malformed`; a transaction over the size bound, 64 KiB decoded, is `aptos/tx-too-large`; a payload that is not an entry function call is `aptos/not-entry-function`; a call that is not the framework `primary_fungible_store::transfer` or `fungible_asset::transfer` with one struct type argument and three arguments is `aptos/not-an-x402-transfer`; and a transaction for a chain other than the option's network is `aptos/chain-mismatch`. | | Cardano | `cardano` | `x402/exact/cardano`, `x402/exact/cardano/lock` | A CIP-20 message (metadata label 674) holding H's LCP string as two strings, `lcp:sha256:0x` and the 64 lowercase hex digits, which the signed body commits to through `auxiliary_data_hash`. A message that repeats a key, or holds a second line reading as the marker in any case or behind a byte-order mark, is refused, so every reader of the chain sees one hash. | | Casper | `casper` | `x402/exact/casper` | The CEP-3009 authorization's `nonce`. | | Concordium | `ccd` | `x402/exact/ccd` | The one transfer's memo: H's LCP string as a CBOR text string, which a PLT transfer wraps in CBOR tag 24. The signed transaction travels in x402's wire form, which `@concordium/web-sdk` gives as `JSON.parse(Transaction.toJSONString(tx))`. | | NEAR | `near` | `x402/exact/near` | The `memo` of the one NEP-141 `ft_transfer` in the NEP-366 delegate action the payer signs. | | | `mpp` | `mpp/charge/nearintents` | The challenge's `externalId`. The deposit carries nothing. | | Polkadot Asset Hub | `polkadot` | `x402/exact/polkadot/lcp-assets-remark` | A `system.remark_with_event` holding H's LCP string with lowercase hex, byte for byte, batched atomically with the asset transfer in one signed extrinsic. | | Starknet | `starknet` | `x402/exact/starknet` | The SNIP-9 outside execution's nonce: H's low 250 bits. | | Stellar | `stellar`, `x402-exact-stellar` | `x402/exact/stellar/precondition` | The transaction's one signed-payload precondition (CAP-40): 40 bytes, H then the nonce of the buyer's Soroban authorization entry, signed by the buyer's key. The form is an agreement, never a charge. | | Sui | `sui` | `x402/exact/sui` | One `Pure` input, H's 32 bytes, that no command uses. | | Tron | `tron` | `x402/exact/tron/lcp-trc20-memo` | The TRC-20 transfer's memo, `raw_data.data`: H's LCP string. | | TON | `tvm` | `x402/exact/tvm` | The Jetton transfer's forward payload: a TEP-74 text comment holding H's LCP string. The pairing serves `tvm:-239` (mainnet) and `tvm:-3` (testnet). The settlement BoC is read as TON deserializes a bag of cells, and each message in it as TON's action phase sends it at the configuration lcp holds for the option's network, which for both is mainnet's: bytes or a settlement message TON refuses are `tvm/boc-malformed`, an outgoing message TON would not send is `tvm/not-jetton-transfer`, a send mode other than 1 or 3, the two x402's TON scheme admits, is `tvm/actions`, and the wallet and Jetton wallet `reference` names are the addresses TON sends to. The W5 request is read as W5's `internal_signed` path reads it: its signature is the body's last 512 bits, and nothing after `has_other_actions` 0 is read. `build` refuses a state init TON deploys no wallet from: one that holds libraries, whose fixed prefix is longer than 8 bits, or whose hash, the bits of its fixed prefix aside, is not the wallet's address, and an attached value above the option's forward TON amount plus 30,000,000 nanotons, the cap of x402's TON facilitator (`@x402/tvm`) (`tvm/value-too-high`). `advertise` reads the stock server's forward payload, the cell of one zero bit, as an empty carrier. | | Stacks | `stacks` | `mpp/charge/usdc/stacks` | The SIP-010 `transfer`'s memo: H's 32 bytes. The signed transaction is read as a Stacks node decodes it: bytes a node does not decode and serialize back to themselves are `mpp/stacks-tx-malformed`. | | Lightning | `lightning` | `mpp/charge/lightning`, `mpp/session/lightning` | The BOLT11 invoice's description hash `h`, which the seller's node signs. | | | | `x402/exact/lnbtc/payment-hash` | Nothing on the invoice: the ATR commits the invoice's payment hash. | | Cloudflare (`cloudflare:402`) | `x402-batch-settlement` | `x402/batch-settlement/cloudflare` | No ledger: the request echoes H in x402's `legalContext` extension and is signed with an HTTP message signature key registered with Cloudflare, which bills off chain. | Where a profile defines the binding, the [pairings reference](https://lcp.integraledger.com/reference/pairings.md) links it, and the profile states the rail's rules clause by clause. ## Peer dependencies Some rails parse or write their wire formats with the rail's own library, which the package declares as an optional peer dependency. Install the one for each rail you use, within the range the package declares: | Rail | Install | Range | |---|---|---| | Solana | `@solana/kit` | `^8.3.0` | | Stellar | `@stellar/stellar-sdk` | `^17.1.0` | | XRP Ledger | `ripple-binary-codec` | `~2.11.0` | | Sui | `@mysten/sui` | `^2.31.3` | | NEAR | `borsh` | `^2.0.0` | | TON | `@ton/core` and its peer `@ton/crypto` | `^0.63.1` (`@ton/core`) | | Algorand | `algosdk` | `^3.8.0` | `ripple-binary-codec` is pinned to a patch range: install `ripple-binary-codec@~2.11.0`. Without its peer, a rail's function gives `/peer-missing` only when it reaches the one step that must decode or write with the peer, after every check that needs none: every other input gets the answer it gets with the peer. Every x402 pairing's option filter reads its options without the peer, so `pairingOf`, `read` and `advertise` need none: Algorand reads its address text and TON its raw addresses, and TON's `advertise` writes the comment's BoC itself, decoding only a forward payload the offer holds in other bytes. Algorand's `bound` and `reference` need no peer. The other functions read or write the transaction with the peer and check everything else first: TON reads a BoC's base64, size, layout and CRC32C before `@ton/core` decodes its cells; Sui's `build` writes its request without `@mysten/sui`, and its `complete` decodes the signed transaction; and the Solana `build`s check every input, a blockhash the choice gives included, before `@solana/kit` writes the message. A `status` or a locate reads as it does with the peer and gives the same answer, after the same calls, wherever it decodes nothing with the peer; a step that must decode with the peer makes a `status` `unreadable`, or a locate's search incomplete, when it is reached, after the reads before it. Of the reads, Stellar's `status` and `stellarLocate` decode only a transaction that succeeded (a search that lists no candidate decodes none), Sui's `status` only a present transaction's bytes that hash to the digest, and TON's `status` decodes the cells it reads itself and compares raw addresses, without `@ton/core`. Every other rail needs nothing more than the package. ## Reading settlement Which read comes first depends on who broadcast the payment. Each pairing's `broadcaster(presented)` answers `"payer"` where the payer sent it before presenting it, so the seller reads the landed payment, and `"payee"` where the seller sends or executes what the payer presents, then reads its settlement; the [pairings page](https://lcp.integraledger.com/concepts/pairings.md#who-broadcasts) lists the pairings that answer by the kind of payment. `status(ref, reader, query)` reads a payment, or an agreement, through a **reader** you supply: an object with a few read-only calls against one network's endpoint. The package makes those calls and nothing else, so the endpoint, the credentials, the timeouts and the retries are yours. Each `status` makes a bounded number of calls. `query` names the act asked about (`payment` or `agreement`) and the finality asked for, one of the rail's marks below, and, where you have them, a final ledger position the transaction must come after (`after`), the search position an earlier `pending` answer returned (`search`), and other acts under the same H (`others`), which `status` never settles on. `status` answers `settled`, `pending`, `failed` or `unreadable`. Every answer but `settled` carries one reason of the closed list the [read-status profile](https://lcp.integraledger.com/profiles/read-status.md) states (rule 12): | State | Reasons | |---|---| | `pending` | `below-mark`, `instrument-live`, `search-incomplete`, `not-found` | | `failed` | `instrument-unused`, `instrument-consumed`, `transaction-failed`, `before-position` | | `unreadable` | `history-gap`, `transport`, `unparseable`, `too-large`, `chain-mismatch` | With it the answer gives the transaction it names, with its ledger position and the mark it read, and the foreign items it met: transactions that carry H and are not the act asked about, each with its reason. Match on these names: no other reason is answered. The profile's rules choose the answer from what the rail's read observes, which the paragraphs below describe rail by rail. Three of them shape every rail's answers. `failed`, for any reason but `before-position`, comes only from a read at the rail's final mark; below it, the same facts answer `pending`, `below-mark`. Where the payer's own signed act carries H, `failed` also needs the search for H read whole. At this release a read on Solana, Sui, Stellar, Algorand, Cardano, Casper, Concordium, Tron, TON or `x402/exact/hedera` answers no `failed` but `before-position`, since its search rests on a fact a run has not yet shown: where the paragraphs below say a read finds the single-use value lapsed (`instrument-unused`), consumed by another act (`instrument-consumed`) or consumed by a failed transaction (`transaction-failed`), `status` answers `pending`, `search-incomplete`, and the search position it returns is where the next call resumes. And an absence is `not-found` only where the reader shows it holds the history the payment would be in; otherwise it is `unreadable`, `history-gap`. A reader that throws or times out never makes a payment failed: a rejected read of the transaction makes `status` answer `unreadable`, with the reason `transport`, or, where the reader rejects with lcp's `ReaderError`, `too-large` for its kind `too-large` and `unparseable` for its kind `malformed` (on EVM chains and the XRP Ledger, `history-gap` for its kind `history`). A later read can settle it; a rejected read of a finality mark counts as that mark not reached. On EVM chains and Tempo, a reader answer that is not a receipt (a `status` of 0 or 1, a bigint `blockNumber` and a list of logs), or a receipt holding a log that is not an object with a string `address`, an array of string `topics` and a string `data`, makes `status` answer `unreadable`, `unparseable`, and `recover` refuses it as `evm/unreadable` or `tempo/unreadable`, the code its rail gives a failed read. A reader that declares a network other than the reference's makes `status` answer `unreadable`, `chain-mismatch`, with nothing read, so no later read through it settles the payment. The package compares only the `network` a reader declares and never asks its endpoint which network it serves, so a reader declares its endpoint's own: one that declares the payment's network over another network's endpoint finds nothing, and where a verdict rests on a point it reads, such as a head, ledger, slot or round, it can read the single-use value as lapsed (`instrument-unused`) for a payment that landed. A reference `status` cannot check is `unreadable`, `unparseable`, with nothing read, and no later read through it settles the payment: - On `x402/exact/eip155/erc7710-salt`, `x402/auth-capture/eip155/eip3009`, `x402/auth-capture/eip155/permit2`, `x402/batch-settlement/eip155`, `mpp/charge/evm/authorization` and `mpp/charge/usdc/evm`, whose `reference` always names the log carrying H or its commitment: a reference without a well-formed log of that event, since the hash cannot be checked. - On the EVM rails: a reference whose transaction is not a 32-byte hash, or whose binding log or transfer log is not of the form its pairing writes. `x402/exact/eip155/eip3009` reads H and the token from the reference's `h` and `asset` rather than its binding log, so an `h` that is not a 32-byte hash or an `asset` that is not an address reads the same; `mpp/charge/evm/transaction` and `mpp/charge/evm/hash` read the token from the reference's `asset`, which their transfer log names, so an `asset` that is not an address reads the same. - On an MPP EVM or Tempo session or a Tempo subscription: a reference whose `opens`, `opened`, `closes`, `accessKey` or `revokes` is not of its form, that names none of the keys its own pairing writes for the opening or the close, or that names a key another of the three writes (see [Channels, sessions and subscriptions](https://lcp.integraledger.com/guides/sessions.md)). - On Casper, Concordium, Starknet, Tron, TON, the XRP Ledger, NEAR, Stacks, Cardano, Aptos, Sui and Stellar, and in the XRP Ledger session close read: a reference that lacks a field `status` compares the landed payment with, or holds it malformed, such as a hash without the `0x` its pairing writes or an address in another encoding; and one whose transaction id on Tron, Cardano, Algorand, Aptos or the XRP Ledger, last valid round on Algorand, sender on Aptos, digest on Sui, request body hash on TON, or asset, recipient, nonce, payload, expiration ledger or starting ledger on Stellar, is malformed. Hex digits in a hash or a hex address read the same in either case; a NEAR account id and a Stacks address read only as their pairing writes them. `status` reads the settlement of the presented transaction. On Tron and NEAR, `reference` takes the token from that transaction, so `status` reports the settlement on the contract the transaction called; on Stacks the reference names the origin, the nonce it signed and the challenge's recipient, and no contract, and on Solana the reference names no token: confirming that it is the token the challenge named is the seller's check. On EVM chains and Tempo, a block above the `finalized` mark can be replaced, by one in which the same transaction succeeds or holds other logs. So what `status` reads from a receipt (a revert, or no authorization use, transfer, binding log, receive-policy guard, Permit2 nonce use or open call where the pairing looks for one) can decide a `failed` answer only when the receipt's block is at or below the reader's `finalized` mark. A failed result read above it, or where that mark cannot be read, is `pending`, `below-mark`, and a later read gives the verdict. An EVM `recover` (`x402/exact/eip155/eip3009`, `x402/exact/eip155/erc7710-salt`, `x402/exact/eip155/permit2`, `x402/upto/eip155/permit2`, `x402/batch-settlement/eip155` and `mpp/session/evm`) places by the same mark a revert and each verdict it reads from the receipt, the settle call it finds with the receipt's `Transfer`, or Permit2's nonce bitmap at the receipt's block (`evm/no-authorization-use`, `evm/no-leaf`, `evm/no-channel-created`, `evm/no-permit2-settle`, `evm/nonce-not-used`, `evm/ambiguous`, and `evm/no-open-call` for an open call whose receipt holds no `Transfer` from its payer): the verdict at or below it, and `evm/not-final`, a read to repeat, above it or where it cannot be read. A transaction whose own call is not an escrow open call is `evm/no-open-call` on every read, since its calldata is its own. A Tempo `recover` (`mpp/session/tempo` and `mpp/subscription/tempo`) places a revert, `tempo/open-not-found`, `tempo/no-witness` and `tempo/ambiguous` by the same mark, with `tempo/not-final` above it or where it cannot be read. Settled answers, and the hash a `recover` gives, are not held to the mark: they carry the mark they reached, or none. On Solana a block at `confirmed` has been voted on by a supermajority of the cluster but can still be replaced, and a transaction in it can land in another block and execute otherwise; a block at `finalized` has reached maximum lockout. So a Solana `status` takes a verdict that rests on how the transaction executed, an error (`err`) or no token or SOL transfer among its instructions and inner instructions, only from the read at `finalized`, the one mark. A transaction met at `confirmed` alone is `pending`, `below-mark`, and a later read gives the verdict. What rests only on the signed message, which the signature fixes, holds from a read at either commitment: a message the payer did not sign, or no single `open` or `top_up` payment-channels instruction, is not the act asked about. An account a transaction takes from an address lookup table, such as an inner instruction's program, is read from the addresses the landed transaction's tables loaded (`SvmLanded.loaded`, `getTransaction`'s `meta.loadedAddresses`), so no table is read; a landed answer whose loaded addresses are not 32-byte keys in exactly the numbers the message's lookups name, or repeat a static key or each other (the runtime refuses a transaction that loads one account twice), reads as `unreadable`. The Solana `recover`s and `fetchPresented` read an error by the same rule: `svm/err` from the read at `finalized`, and `svm/not-final`, a read to repeat, from the read at `confirmed` alone. On Stellar the payer signs an authorization entry for the transfer, not the transaction that carries it, and a transaction that fails leaves the entry unused. The reference names no transaction: `status` finds the agreement by a search of the buyer's acts, `getEvents` on every contract for the buyer's SEP-41 `transfer` events, from the reference's `fromLedger`, the ledger recorded at issue, through the latest closed ledger, which `getLatestLedger` gives first, each candidate transaction read whole with `getTransaction`. A page whose `latestLedger` is below that first read leaves the search not read through, and the answer gives the position the next call resumes at. It settles on a transaction that consumed the entry's nonce under the five checks of the profile [`x402-exact-stellar-precondition`](https://lcp.integraledger.com/profiles/x402-exact-stellar-precondition.md). The value is read lapsed where the latest closed ledger is above the entry's expiration ledger, but no run has yet shown that an event search with no contract named holds every act of the buyer, so every answer the read decides but `before-position` is `pending`, `search-incomplete`. The reader's `events` takes `fromLedger` through `toLedger`, both inclusive. Stellar RPC's `getEvents` treats `endLedger` as exclusive and takes a cursor or a ledger range but not both, so a reader over it sends `startLedger: fromLedger` and `endLedger: toLedger + 1` on the first page and only the cursor after that, returns a `cursor` while pages remain (until `getEvents` has scanned through `toLedger`, or through its own `latestLedger` where that is lower), even when a page holds no events, and keeps only the events through `toLedger`, since a cursor page can scan past it. Each page also returns `getEvents`' `oldestLedger` and `latestLedger`; an RPC whose oldest ledger is above the search's start is `unreadable`, `history-gap`. On Sui, a node keeps only recent history, so an absent transaction can be one the endpoint has pruned. `suiStatus(ref, reader, query)` takes in `query.after` the checkpoint from which you need history, such as the latest checkpoint when the payment is requested. It reads an absent transaction as lapsed (`instrument-unused`) only when the epoch is past the transaction's bound and the endpoint holds transactions from that checkpoint or earlier. Where the endpoint does not hold them, the answer is `unreadable`, `history-gap`; where the epoch is not past the bound, an absent transaction can still land, and the answer is `pending`, `instrument-live`. Until a run shows the facts the search for H rests on, a lapse is answered `pending`, `search-incomplete`, never `failed`. A transaction that sets no maximum epoch can execute in any later epoch: `reference` records it with a null `untilEpoch`, and `suiStatus` never reads it as lapsed. On Cardano, a recent block can still be rolled back. `cardanoStatus(ref, reader, query)` counts a transaction's confirmations up to the ledger's security parameter, read from the endpoint's genesis, which is the final mark, and reads the body's TTL as passed only when the block that many blocks below the tip is at or past its TTL slot, so a rollback above that depth leaves a payment that landed pending, never failed. The ledger takes a transaction only in a slot below its TTL (`invalid_hereafter`), so the TTL slot is the first in which it cannot land. On Aptos, the ledger takes a transaction only while its time, in whole seconds, is below the transaction's `expiration_timestamp_secs` (the prologue's `timestamp::now_seconds() < txn_expiration_time`), so that second is the first in which it cannot commit. `aptosStatus(ref, reader, query)` reads the sender's transaction at the signed sequence number; where there is none, it reads the sender's account, whose sequence number and ledger timestamp come in one answer. A number the account has passed was consumed by a transaction the lookup did not return (`pending`, `search-incomplete`); one it has not passed is lapsed (`instrument-unused`) once that answer's ledger timestamp, in whole seconds, is at or past the reference's `expiresAt`, and live (`instrument-live`) before. Either verdict needs the history: where the endpoint's oldest version is above the position given in `query.after`, or no position is given, the answer is `unreadable`, `history-gap`. On the rails in the table below, a verdict that a payment will never land rests on a reference point: a head time, a ledger, a confirmed nonce, a final height, a chain tip or the slot of a nonce account read. The reference point is read before the lookup it judges, and a lookup shows the payment absent only up to the point its own source had reached. So the reader's answer names that point, in the answer itself or read from the source that answered before the lookup, and the verdict needs it at or past the reference point. A payment that lands between the two reads, or that a lookup misses because its source lags the reference point, as one node behind a load-balanced endpoint can, stays pending (NEAR's `status` answers `pending`), never failed, and so does one whose answer names no point. A later read, once that source has caught up, gives the verdict. The rule governs the reading of a lapse (`instrument-unused`) on Tron, TON, Stellar, NEAR and Cardano, and of a named Solana durable-nonce transaction that no lookup finds and whose nonce account no longer holds its value (`instrument-consumed`); on the rails whose search is not yet read whole, such a reading is answered `pending`, `search-incomplete`. Aptos needs no second point: the account's sequence number and the ledger timestamp it is judged by come in one answer. Stacks reads no absence this way: its read holds the origin's nonce, read at the chain tip, so a nonce not consumed there is `instrument-live`, and one consumed whose transaction no lookup finds is `search-incomplete`, never `not-found`. On Solana `getTransaction` names no slot when it finds nothing, so a reader reads `getSlot` at the lookup's commitment from the node that answers, before the lookup, and must pin one node to name it; a reader that cannot names no slot. | Rail | The reference point, read first | What the answer that finds nothing names | |---|---|---| | Tron | the latest solidified block's time | `{ notFound: true, timestamp }`: the time of the latest block at the lookup's level on the node that answered | | TON | the masterchain head's `gen_utime` | `indexed()`: the index's statement of a finalized masterchain block through which it holds every block, with its `gen_utime`, on which the expiry read decides | | Stellar | `getLatestLedger`, read before the events search | each events page's `latestLedger` | | NEAR | the final block height | the key read's `blockHeight`, `view_access_key`'s `block_height` | | Cardano | the chain tip's slot | `{ notFound: true, slot }`: the slot of the latest block the indexer that answered held | | Solana | the context slot of the durable nonce account's read (`getAccountInfo` at `finalized`) | `{ notFound: true, slot }`: the slot at the lookup's commitment of the node that answered, read before the lookup | On TON, `status` counts only a Jetton transfer that a run of the payer's W5 wallet sent, since W5 checks the signature before it sends anything; an equal transfer body executed any other way never settles. A request the wallet has run stays pending `search-incomplete`, held at its transaction, until its Jetton transfer lands, however late, because an internal message carries no expiry. Its lapse is the expiry read of the profile [`x402-exact-tvm`](https://lcp.integraledger.com/profiles/x402-exact-tvm.md) (rule 6): the wallet's state, its transactions linked back to the position, and the index's statement of the blocks it holds. That an index lists whole is not yet shown by a run, so until it is the expiry read releases nothing: no answer but `before-position` is `failed`. | Rail | Reader | Its calls | Marks (a settled answer carries the one it reached) | |---|---|---|---| | EVM chains, Tempo | `EvmReader` | `eth_getTransactionReceipt`, `eth_getBlockByNumber` for the `safe` and `finalized` marks, `eth_getTransactionByHash`, `eth_call` at a block number; and, where the reader gives them, `eth_getLogs` over a block range (without it a read that needs a search answers no `failed` that rests on one) and `eth_getBlockByNumber` for a block's timestamp (without it no lapse is read) | `latest`, `safe` or `finalized` | | Solana | `SvmReader` | `getTransaction` at a commitment, with encoding `base64` and `maxSupportedTransactionVersion: 1` (asked with 0, a node answers a version-1 transaction with an error, and a version-1 payment never reads settled), with the node's slot at that commitment (`getSlot`) read before it when it finds nothing, `getSignaturesForAddress`, with `minContextSlot` when the search names one, `getFirstAvailableBlock`, `getAccountInfo` at `finalized` for a durable nonce account; and `isBlockhashValid` at a commitment, with its context slot, by which the read finds a blockhash message lapsed | `finalized`, the one mark | | Stellar | `StellarReader` | `getNetwork` (the passphrase), `getLatestLedger`, `getTransaction`, `getEvents` on every contract for the buyer's SEP-41 `transfer` events, with each page's `oldestLedger` and `latestLedger`, and optionally `getLedgerEntries` of an account (its sequence number) | `finalized`, the one mark | | XRP Ledger | `XrplReader` | `server_info`; `tx` by hash, within a ledger range where one is given; `account_tx` of the payer, forward and binary, a page at a time; `account_info` and `ledger_entry` (a `Ticket`, a `PayChannel`) at a named ledger | `validated`, with the ledger index | | Hedera | `HederaReader` | the Mirror Node's transaction by id, where a rejected duplicate or a node due-diligence failure (`INVALID_NODE_ACCOUNT`, `INVALID_PAYER_SIGNATURE`) leaves the id free for the transaction itself; its latest and oldest consensus timestamps (`/api/v1/blocks`); an account's transactions, a page at a time | `consensus`, with the consensus timestamp | | Algorand | `AvmReader` | the Indexer's transaction by id with its `current-round`; a block header by round (`header-only`), not read where the reader is declared `archival`; an account's transactions by round range, a page at a time | `final`, with the confirmed round | | Aptos | `AptosReader` | the ledger info (`GET /v1`), read first; the transaction by hash; the sender's transaction by sequence number, with the ledger timestamp of its answer; the sender's account | `committed`, with the version | | Cardano | `CardanoReader` | the security parameter from the endpoint's genesis; the chain tip, read first; the slot of the block at a height; the output an input names, with the transaction that spent it; the transaction by id, with the indexer's latest slot when it holds none; the addresses that hold a transaction's inputs; a payment credential's transactions, by page | counts of confirmations, the final one the ledger's security parameter | | Casper | `CasperReader` | `info_get_transaction`; the newest executed block; the lowest block whose state the node serves; the token's `used_nonces` item with `state_get_dictionary_item` at a block's state root; a block's executed transactions, a page at a time | `finalized`, with the block height | | Concordium | `CcdReader` | gRPC `GetConsensusInfo`, `GetBlockInfo` at a height, `GetAccountInfo` at a height or the latest head, `GetBlockItems` at a height, `GetBlockItemStatus` | `committed` or `finalized` | | NEAR | `NearReader` | `EXPERIMENTAL_tx_status`, the final block height, `view_access_key` at final and at the latest head with its `block_height`, `changes` for one access key and for every key of an account | `final` when the status is `FINAL` and the change is at or below the final height, else `optimistic` | | Polkadot Asset Hub | `PolkadotReader` | `polkadot-rest-api`'s extrinsic by block and index, a block's raw extrinsics, the finalized head and the latest head, the account's nonce at the finalized block or the head (`/accounts/{account}/balance-info`); and `TaggedTransactionQueue_validate_transaction` through the JSON-RPC endpoint's `state_call` | `finalized` or `head` | | Starknet | `StarknetReader` | the newest `ACCEPTED_ON_L1` and `ACCEPTED_ON_L2` blocks, `is_valid_outside_execution_nonce` on the payer's account at a block, `starknet_getEvents` on the asset a page at a time, `starknet_getTransactionReceipt` with its events, `starknet_traceTransaction` | `ACCEPTED_ON_L2` or `ACCEPTED_ON_L1` | | Sui | `SuiReader` | the transaction by digest, with the current epoch and the first checkpoint the endpoint holds transactions from; the sender's transactions between two checkpoints, a page at a time (the search for H) | `executed` or `final`, with the checkpoint | | Tron | `TronReader` | the latest solidified block, read first; `gettransactioninfobyid` at the solidified or head level, with the node's latest block time at that level when it finds nothing; `gettransactionbyid`; blocks by range (`getblockbylimitnext`) and by number (`getblockbynum`) at a level | `solidified` or `head` | | TON | `TvmReader` | the masterchain head, read first; the index's statement of the blocks it holds; Toncenter's transactions by message body hash (the signed W5 request's); the wallet's state and its transactions by account, each with its predecessor and the account's state before and after it; by message hash (the Jetton transfer a run sent, then the `internal_transfer` it led to) and by hash; and `runGetMethod`'s `get_wallet_data` and `get_wallet_address` | `confirmed` or `finalized` | | Stacks | `StacksReader` | the chain tip's Stacks and Bitcoin heights (`GET /extended`), read first; the reference's transaction by id with its events and bytes, a hint; the origin's last executed nonce at the tip or at a height; the lookup by origin and nonce, or for nonce 0 a scan of the origin's transactions; a block's transactions, the lookup's fallback; the Bitcoin height of the burn block of the tenure after a block's | `block` or `bitcoin` | On EVM chains, a reader rejects with `ReaderError` and one of the kinds `timeout`, `too-large`, `transport`, `malformed` or `history` (the endpoint does not hold the range or block asked for). The other rails' readers may reject with it too, as each interface's documentation states. An `XrplReader` rejects with the kind `history` where the server refuses a call for ledgers it does not hold: rippled on API version 2 answers `account_tx` from a ledger below those it holds with `lgrIdxMalformed`, and the read answers `unreadable`, `history-gap`, so you read again through a server that holds them. The [seller guide](https://lcp.integraledger.com/guides/seller.md#the-whole-flow) builds an `EvmReader` from one receipt and reads a settlement through it. A Solana message lives until its recent blockhash's validity ends, 150 blocks after the blockhash's own block, unless it uses a durable nonce: its first instruction is the System program's `AdvanceNonceAccount`, naming a writable nonce account as a static key, the `RecentBlockhashes` sysvar and the nonce authority as a signer, and its blockhash field holds the nonce value. Such a message lands only while the nonce account holds that value. Its reference records `nonce`, the account and the value, and an empty `blockhash`. The sysvar may come from an address lookup table: the runtime resolves it and checks it when `AdvanceNonceAccount` runs, and the reference records the nonce the same way. A durable message names its nonce account as a static key (SIMD-0242), so `bound` and `reference` refuse a message whose `AdvanceNonceAccount` takes its nonce account from a lookup table with `svm/nonce-account-not-static`. A Solana `status` (`svmStatus`, `svmChannelStatus`, and each Solana pairing's `status`) reads one mark, `finalized`. It searches for H in the memo-carrying signatures of the buyer's own account, which every transaction the buyer signs loads, never the fee payer's, from the position given to the latest head (`confirmed`, which is no mark), 10 pages of 1,000 and 50 candidates a pass; a pass not read whole answers `pending`, `search-incomplete`, with the handle (`search`) the next call takes. It reads a durable nonce's account at `finalized` and at the latest head. For a blockhash message it takes the first `isBlockhashValid` answer of `true` at `confirmed`, whose context slot bounds the blockhash's own slot from above and which the handle keeps; it reads the blockhash lapsed only where `isBlockhashValid` answers `false` at `finalized` at a slot at least 150 past that bound, since a slot count alone decides nothing: a skipped slot adds no block. Until a run shows that the buyer's signatures list every transaction the buyer signs (`SVM_SEARCH_SHOWN`), a search read whole proves no absence: the read answers no `failed` but `before-position`, and `pending`, `search-incomplete` where it would answer `instrument-unused`, `instrument-consumed` or `transaction-failed`. The profiles `x402-exact-solana` and `read-status` state the read whole. Lightning has no settlement read: the invoice and its preimage, which the parties hold, show that the invoice was paid. They do not show who paid it, and no public ledger shows the payment. Its pairings give `reference` and no `status`. On Lightning, `build` checks the binding and the invoice's form: that the invoice carries H where its pairing places it, that it answers this request, and that its currency is the one the network names. It verifies no signature and does not compare the invoice's amount or payee with the offer: those checks are the payer's, done by its wallet or node. ## Recovering H from the chain alone On some pairings anyone can read H back from the settled transaction alone, without either party. Those pairings have `recover({ network, tx, option }, reader)` and `pattern.zeroPartyRecoverable` set: the network, the settlement transaction's id, and the x402 option or MPP challenge the ATR's binding slot holds, from which each rail's read takes what it needs, as its profile states. This example lists them from the registry: ```ts import { BINDINGS } from "@integraledger/lcp"; const recoverable = BINDINGS.filter((b) => "pattern" in b && b.pattern.zeroPartyRecoverable).map((b) => b.id); console.log(recoverable.length); console.log(recoverable.sort().join("\n")); ``` ```text 32 mpp/charge/lcp/hedera mpp/charge/solana mpp/charge/solana/unsponsored mpp/charge/usdc/solana mpp/charge/usdc/stacks mpp/charge/xrpl mpp/session/evm mpp/session/solana/memo mpp/session/tempo mpp/session/xrpl mpp/subscription/solana mpp/subscription/tempo x402/batch-settlement/eip155 x402/batch-settlement/solana x402/exact/algorand x402/exact/cardano x402/exact/cardano/lock x402/exact/casper x402/exact/ccd x402/exact/eip155/eip3009 x402/exact/eip155/erc7710-salt x402/exact/eip155/permit2 x402/exact/hedera x402/exact/near x402/exact/polkadot/lcp-assets-remark x402/exact/solana x402/exact/stellar/precondition x402/exact/sui x402/exact/tron/lcp-trc20-memo x402/exact/tvm x402/upto/eip155/permit2 x402/upto/solana ``` Two pairings that keep no H on chain have a `recover` that returns the value the transaction carries in H's place, which a holder of the ATR computes from its own H and compares: `x402/exact/starknet` returns the outside execution's nonce, H's low 250 bits, and `x402/exact/xrpl` the `Payment`'s `InvoiceID`, the SHA-256 of H's LCP string. Where H is only in calldata, `recover` reads the transaction as well as its receipt: - `x402/exact/eip155/permit2` and `x402/upto/eip155/permit2` read the Permit2 nonce of the scheme's x402 proxy call (`settle` or `settleWithPermit`) found at any byte offset of the transaction's input, directly or inside a batched call or an ERC-4337 bundle, where the receipt holds a `Transfer` that the call's token emits from the call's owner (its recipient and value are not compared), and where Permit2 marks that nonce used for the owner in the receipt's block and not before, the Permit2 read `status` makes. No signature is checked, and Permit2's mark is per block, whether a settlement or the owner's `invalidateUnorderedNonces` set it: any transaction of that block whose input carries a call with the same nonce and owner, and whose receipt holds a `Transfer` from that owner emitted by the contract that call names as its token, gives H. `status` with the ATR's reference tells which transaction paid. - `mpp/session/evm` reads the salt of the escrow's open call (`open`, `openWithAuthorization` or `openWithPermit2`) that the transaction itself makes, where the receipt holds a `Transfer` of the call's token, of any value, from the call's payer into the called contract. It refuses an opening sent through an ERC-4337 EntryPoint (`evm/no-open-call`), whose calldata does not show which contract the account called, and so one whose calldata is longer than 131,072 bytes, go-ethereum's transaction pool maximum, which the read does not decode. `mpp/session/tempo` reads only the receipt: the salt is data word 3 of the `ChannelOpened` log of the TIP-20 channel reserve (TIP-1034). A v1 escrow's `ChannelOpened` carries no salt, and the reader does not show a Tempo transaction's calls, so a v1 opening is refused (`tempo/open-not-found`, once its block is at or below the reader's `finalized` mark). ## Where the payment is not a public proof On some pairings the settlement leaves no public record that commits to H: `data.coverage` is `none`. H still rides in the challenge, and each pairing's record says what its payment shows. On most of them nothing the buyer signs carries H either. On the MPP Lightning pairings the invoice carries H, and on x402's the ATR commits the invoice's payment hash; the invoice and its preimage are held by the parties, and no public ledger shows them. On `x402/exact/eip155/gateway-batched` the nonce of the authorization the payer signs is H; Circle Gateway settles it in batches, and no public ledger shows it. For these pairings the seller advertises an [agreement URL](https://lcp.integraledger.com/concepts/buyer-gate.md#the-agreement-url) beside the link, and the buyer gate declines such an offer without one: the buyer first pays that URL, whose payment is a public proof of H, and then the full payment. This example lists the x402 and MPP pairings it applies to: ```ts import { BINDINGS } from "@integraledger/lcp"; const rails = BINDINGS.filter((b) => /^(x402|mpp)\//.test(b.id) && b.data.coverage === "none").map((b) => b.id); console.log(rails.sort().join("\n")); ``` ```text mpp/charge/card mpp/charge/evm/hash mpp/charge/evm/transaction mpp/charge/lightning mpp/charge/nearintents mpp/charge/stripe mpp/charge/usdc/gateway mpp/session/hedera/stock mpp/session/lightning mpp/session/solana/stock mpp/session/xrpl/stock mpp/subscription/stripe x402/batch-settlement/cloudflare x402/exact/aptos x402/exact/eip155/erc7710 x402/exact/eip155/gateway-batched x402/exact/hedera/transfer-executor x402/exact/lnbtc/payment-hash x402/upto/xrpl ``` The checkout pairings are the same where the buyer's approval does not sign H; see [Agentic checkouts](https://lcp.integraledger.com/guides/checkouts.md). ## Next - [Binding](https://lcp.integraledger.com/concepts/binding.md): the binding patterns and the `pattern` record. - [x402](https://lcp.integraledger.com/guides/x402.md) and [MPP](https://lcp.integraledger.com/guides/mpp.md): the protocols these rails settle under. --- # Discovery > The discovery document a seller publishes at /.well-known/legal-context.json, and how emit and parse write and read it. Source: https://lcp.integraledger.com/guides/discovery Updated 2026-10-13. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. A seller can publish a **discovery document** (`LCP §2`): one small JSON object, served at `/.well-known/legal-context.json` on the seller's host, that names the seller's terms document and how to reach the seller. Because the path is fixed, an agent finds it from the host name alone. A service that implements the standard serves it (`LCP §2.1`: *"A service implementing this standard MUST serve a JSON document"* at `https://{domain}/.well-known/legal-context.json`). The discovery document is not an ATR. It describes the seller's standing terms and is the same for every request; an ATR is the record of one transaction, and its hash rides in that transaction's payment. Nothing in a pairing reads the discovery document. `LCP §2.5` says of `atrHash` that *"the ATR is the terms document itself (the standalone artifact of Section 2.3), and `atrHash` is its digest"*; in this package the ATR is the per-transaction record whose hash rides in the payment, so a discovery `atrHash` is the digest of the standing terms, not a payment's H. Import the pieces from `@integraledger/lcp/discovery`: | Export | What it is | |---|---| | `emit(document)` | The document's bytes: its members checked and written in a fixed order, or a refusal. | | `parse(bytes)` | The document read from bytes, with the names of the members it ignored, or a refusal. | | `WELL_KNOWN_PATH` | `"/.well-known/legal-context.json"` | | `MAX_DOCUMENT_BYTES` | `65536`: the largest document either function accepts. | | `LegalContextDocument` | The document's type. | Neither function throws or does any I/O. Serving the bytes, and fetching them, are yours. ## The members These are the members `LCP §2.4` and `LCP §2.5` define, in the order their tables list them. Their meanings are the specification's; the last column is what `emit` and `parse` check. | Member | Type | Checked | |---|---|---| | `terms` | string | Required. An absolute `https` URL that meets the [link rule](https://lcp.integraledger.com/concepts/atr-hash.md#the-link). | | `termsFormat` | string | Not empty. | | `atrHash` | string | The digest of the document at `terms` (`LCP §2.5`): `0x` and 64 hex digits, in either case. It is written in lowercase. | | `acceptanceRequired` | boolean | A boolean. | | `disputeResolution` | object | Its members `method`, `jurisdiction`, `contact`, `clauseId`, `source` and `catalog`, in that order, each a non-empty string. `clauseId` is `sha256:0x` and 64 hex digits. | | `returns` | string | Not empty. | | `contact` | object | Its members `legal` and `technical`, each a non-empty string. | | `api` | string | Not empty. | Every member other than `terms` is optional. An absent member is left out, never written as `null`. ## Writing the document `emit(document)` checks each member, then writes the members in the table's order, with no whitespace, strings escaped as `JSON.stringify` escapes them, and `atrHash` in lowercase. A member the table does not name is not written, so a seller cannot publish an extension member with `emit`; `LCP §2.5` says *"The field set is extensible."* The result is at most `MAX_DOCUMENT_BYTES`. This example writes the reference document from the package's vectors, whose `atrHash` is SHA-256 of `"abc"` given in upper case: ```ts import { hash, isRefusal } from "@integraledger/lcp"; import { emit, WELL_KNOWN_PATH, type LegalContextDocument } from "@integraledger/lcp/discovery"; const document: LegalContextDocument = { terms: "https://seller.example/terms/v3.md", termsFormat: "markdown", atrHash: "0xBA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD", acceptanceRequired: false, contact: { legal: "legal@seller.example" }, }; const bytes = emit(document); if (isRefusal(bytes)) throw new Error(bytes.code); console.log(WELL_KNOWN_PATH); console.log(new TextDecoder().decode(bytes)); console.log(bytes.length, "bytes"); console.log(`ETag: "${(await hash(bytes)).slice(2)}"`); ``` ```text /.well-known/legal-context.json {"terms":"https://seller.example/terms/v3.md","termsFormat":"markdown","atrHash":"0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad","acceptanceRequired":false,"contact":{"legal":"legal@seller.example"}} 220 bytes ETag: "027d93681365deb2f485c4c34f7b0da7de8741db90a9fa6ea2437aa70bebd31a" ``` Serve those bytes at `WELL_KNOWN_PATH`, over `https` (`LCP §2.1`), with `Content-Type: application/json` (`LCP §2.2`: *"The discovery document MUST be valid JSON (`application/json`)."*). The same input always gives the same bytes, so a strong ETag over them is stable: [`vectors/discovery.json`](https://lcp.integraledger.com/vectors/discovery.json) fixes it as the SHA-256 in hex, in double quotes. ## Reading a document `parse(bytes)` reads what a seller served. It accepts one JSON object of at most `MAX_DOCUMENT_BYTES`, in well-formed UTF-8 without a byte-order mark, nested at most 64 levels deep, and checks each member as the table says. Where a member appears twice, the last one is read, as `JSON.parse` reads it. A member the table does not name, at the top level or inside `disputeResolution` or `contact`, is left out of `document` and named in `ignored` by its dotted path, so you can see what the seller sent that the specification does not define. ```ts import { parse } from "@integraledger/lcp/discovery"; import { isRefusal } from "@integraledger/lcp"; const served = new TextEncoder().encode( JSON.stringify({ terms: "https://seller.example/terms/v3.md", atrHash: "0xBA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD", contact: { legal: "legal@seller.example", phone: "+1 555 0100" }, "x-region": "eu", }), ); const read = parse(served); if (isRefusal(read)) throw new Error(read.code); console.log(read.document); console.log(read.ignored); const overHttp = parse(new TextEncoder().encode('{"terms":"http://seller.example/terms/v3.md"}')); console.log(isRefusal(overHttp) ? overHttp.code : "read"); ``` ```text { terms: 'https://seller.example/terms/v3.md', atrHash: '0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', contact: { legal: 'legal@seller.example' } } [ 'contact.phone', 'x-region' ] discovery/terms-not-https ``` `emit` over the `document` that `parse` returns writes it in the fixed order, so every reader of one document can hold the same bytes. ## Refusals | Code | When | |---|---| | `discovery/too-large` | The bytes, or the document `emit` would write, exceed `MAX_DOCUMENT_BYTES`. | | `discovery/not-json-object` | The input is not a `Uint8Array`, or the bytes are not one JSON object: not JSON, not UTF-8, a byte-order mark, an array, or nested more than 64 levels. `emit` gives it for an input that is not an object. | | `discovery/terms-missing` | `terms` is absent. | | `discovery/terms-not-https` | `terms` is not an absolute `https` URL that meets the link rule. | | `discovery/atr-hash-malformed` | `atrHash` is not `0x` and 64 hex digits. | | `discovery/clause-id-malformed` | `disputeResolution.clauseId` is not `sha256:0x` and 64 hex digits. | | `discovery/member-malformed/` | The member at `` has the wrong type, or is an empty string: for example `discovery/member-malformed/contact.legal`. | ## Fetching it The fetch is yours. Bound it as you bound any fetch of a seller's bytes: one `GET` to `https:///.well-known/legal-context.json`, a deadline, and a body cancelled once it passes `MAX_DOCUMENT_BYTES`. Then pass the bytes to `parse`. Cache what `parse` returns for at most 24 hours, and fetch the document again once that expires (`LCP §2.6`). ## Next - [The ATR](https://lcp.integraledger.com/concepts/atr.md): the per-transaction record a payment is bound to. - [Vectors](https://lcp.integraledger.com/concepts/vectors.md): `vectors/discovery.json` fixes what `emit` writes and what `parse` reads or refuses. Its `parse` rows include the four examples of `LCP §2.7`, byte for byte, each read as a document, and one `emit` row writes the values of the Full example. --- # Run the settler > Start the settler, configure its modules, keys, credential and fee budget, and call it. Source: https://lcp.integraledger.com/guides/settler Updated 2026-11-20. Documents @integraledger/lcp 0.6.3 and @integraledger/profile-facilitator 0.5.1. The settler, `@integraledger/profile-facilitator`, is an x402 facilitator that holds each payment to its pairing's LCP profile (hence the package name), for the x402 pairings `@integraledger/lcp` implements: one HTTP surface, `GET /supported`, `POST /verify` and `POST /settle`, on x402's own facilitator class with one module per chain ([the settler](https://lcp.integraledger.com/concepts/settler.md)). This guide is for the operator who runs it: at the end you can install it, configure each module with its keys, nodes and database, put it behind TLS, and call it. Its programs need Postgres and the package itself, so they are marked `no-check`: the documentation's check, which runs every other program in these pages, does not run them. ## Install ```sh npm install @integraledger/profile-facilitator @integraledger/lcp@~0.6.3 ``` It needs Node.js `>=24.22.1`, Postgres 11 or later ([The database](https://lcp.integraledger.com/guides/settler.md#the-database)), and, for each network it serves, the node its module reads. It is ESM only. `@integraledger/lcp` is its peer dependency, at `~0.6.3`: install it with the settler ([Versions](https://lcp.integraledger.com/guides/settler.md#versions)). A module that holds a key takes it as the signer object of x402's class for that chain; make it with that chain's x402 package at 2.31.0, the release the settler's classes are pinned to (`@x402/evm`, `@x402/svm`, `@x402/avm`, and so on). Two packages in its dependency tree have install scripts that it runs without: `protobufjs` (through `@hiero-ledger/sdk` and `@concordium/web-sdk`) and `secp256k1` (through `@x402/near`). This repository installs with both denied, and runs the settler's tests so. pnpm 12 stops an install at a build script it has no decision for (`ERR_PNPM_IGNORED_BUILDS`); deny both in your `pnpm-workspace.yaml`: ```yaml permissions: protobufjs: {build: false} secp256k1: {build: false} ``` With npm, `npm install --ignore-scripts` runs neither. A project that installs under pnpm's `trustPolicy: no-downgrade`, as this repository does, excludes exactly two versions from it, and nothing wider: ```yaml trustPolicy: no-downgrade trustPolicyExclude: - '@noble/ed25519@1.7.5' - '@noble/secp256k1@1.7.2' ``` The Casper module registers `@x402/casper` 2.31.0, which pins `casper-js-sdk` 5.1.1; every `casper-js-sdk` from 5.1.1 to 5.3.1 requires `@noble/ed25519` `^1.7.5` and `@noble/secp256k1` `^1.7.2`, with which it verifies a payer's ed25519 and secp256k1 signatures and signs with the settler's key, and no version of either package avoids them. Both were published in April 2025 as maintenance releases of the packages' 1.x lines without provenance, after each package's 2.1.0 had been published with it in March 2024, so `no-downgrade` refuses them. Every other version of the two packages, and every other package, stays under the policy. A pnpm project that turns hoisting off (`hoist: false`) also declares, for the Concordium module, the one dependency `@concordium/web-sdk` 12.0.2 imports without declaring it, `@protobuf-ts/runtime`; without it the module does not load ("Cannot find package '@protobuf-ts/runtime'"). With hoisting on, pnpm's default, and with npm, nothing is needed. ```yaml packageExtensions: "@concordium/web-sdk@12.0.2": dependencies: "@protobuf-ts/runtime": "2.11.1" ``` ## Start it and read what it supports Start the settler for Tron mainnet and Polkadot Asset Hub, and read what it supports. Neither module holds a key, so this deployment needs no credential. The node URLs are your own nodes; the settler calls them only when a payment arrives. `DATABASE_URL` is your Postgres connection string. ```ts no-check title="supported.ts" import { serveProfileFacilitator } from "@integraledger/profile-facilitator"; const settler = await serveProfileFacilitator({ listen: "127.0.0.1:4020", store: { url: process.env.DATABASE_URL ?? "postgres://postgres@127.0.0.1:5432/postgres" }, settleWaitMs: 30_000, tron: [{ network: "tron:728126428", fullNode: "http://127.0.0.1:8090", solidityNode: "http://127.0.0.1:8091" }], polkadot: [{ network: "polkadot:68d56f15f85d3136970ec16946040bc1", rpc: "http://127.0.0.1:9944" }], }); const supported = await (await fetch("http://127.0.0.1:4020/supported")).json(); console.log(JSON.stringify(supported, null, 2)); await settler.close(); ``` ```text { "kinds": [ { "x402Version": 2, "scheme": "exact", "network": "polkadot:68d56f15f85d3136970ec16946040bc1", "extra": { "assetTransferMethod": "lcp-assets-remark", "key": "none", "acceptsZero": [], "pairings": [ "x402/exact/polkadot/lcp-assets-remark" ] } }, { "x402Version": 2, "scheme": "exact", "network": "tron:728126428", "extra": { "assetTransferMethod": "lcp-trc20-memo", "key": "none", "acceptsZero": [], "pairings": [ "x402/exact/tron/lcp-trc20-memo" ] } } ], "extensions": [], "signers": { "polkadot:*": [], "tron:*": [] } } ``` ## Run it as a service The package exports one function that starts the server; it has no command-line entry. It reads no environment variable and no file: every setting is a member of the configuration, and the variable names in these samples are the samples' own. A service is a short module that reads its configuration, makes the signer objects its keyed modules take, and stops cleanly on a signal. This one serves x402's `exact` scheme on Base Sepolia through the `evm` module, whose key, the seller's gas key, sends each transaction and pays its gas: ```ts no-check title="settler.ts" import { serveProfileFacilitator } from "@integraledger/profile-facilitator"; import { toFacilitatorEvmSigner } from "@x402/evm"; import { createWalletClient, http, publicActions, type Hex } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { baseSepolia } from "viem/chains"; const rpc = process.env.BASE_SEPOLIA_RPC ?? "http://127.0.0.1:8545"; const credential = process.env.SETTLER_CREDENTIAL; const gasKey = process.env.SELLER_GAS_KEY as Hex | undefined; if (credential === undefined || gasKey === undefined) throw new Error("set SETTLER_CREDENTIAL and SELLER_GAS_KEY"); // The seller's gas key, as x402's EVM classes take it. const account = privateKeyToAccount(gasKey); const client = createWalletClient({ account, chain: baseSepolia, transport: http(rpc) }).extend(publicActions); const signer = toFacilitatorEvmSigner( { address: account.address, getCode: (a) => client.getCode(a), readContract: (a) => client.readContract({ ...a, args: a.args ?? [] } as never), verifyTypedData: (a) => client.verifyTypedData(a as never), writeContract: (a) => client.writeContract({ ...a, args: a.args ?? [] } as never), sendTransaction: (a) => client.sendTransaction(a as never), waitForTransactionReceipt: (a) => client.waitForTransactionReceipt(a) as never, simulateCalls: (a) => client.simulateCalls(a as never) as never, }, // Below settleWaitMs, so /settle answers settlement_pending instead of waiting up to x402's default 180 s. { confirmationTimeoutMs: 25_000 }, ); const listen = process.env.LISTEN ?? "127.0.0.1:4021"; const settler = await serveProfileFacilitator({ listen, store: { url: process.env.DATABASE_URL ?? "postgres://postgres@127.0.0.1:5432/postgres" }, settleWaitMs: 30_000, credential, evm: [{ network: "eip155:84532", rpc, signer, schemes: ["exact"] }], // At most 0.01 ETH of gas in any 24 hours; past it, payments whose gas the key pays are refused. feeBudgets: [{ network: "eip155:84532", amount: "10000000000000000", periodSeconds: 86_400 }], }); for (const signal of ["SIGINT", "SIGTERM"] as const) { process.once(signal, () => { void settler.close().then(() => process.exit(0)); }); } console.log(`settler listening on ${listen}`); ``` ```text settler listening on 127.0.0.1:4021 ``` `@x402/evm`'s signer waits up to 180 s for a receipt unless `toFacilitatorEvmSigner`'s `confirmationTimeoutMs` is set, and a class's settle takes no deadline from the settler, so the sample sets it below `settleWaitMs`. Run it with `node settler.ts`: Node.js 26 runs TypeScript directly. Every call must then carry `Authorization: Bearer `. Its `/supported` states: ```json no-check { "kinds": [ { "x402Version": 2, "scheme": "exact", "network": "eip155:84532", "extra": { "key": "relayer", "acceptsZero": ["x402/exact/eip155/eip3009"], "pairings": ["x402/exact/eip155/eip3009", "x402/exact/eip155/permit2"], "feeBudget": true } } ], "extensions": [], "signers": { "eip155:*": [""] } } ``` `close()` stops accepting requests, closes open connections, closes what each module opened (the Polkadot nodes' connections among them), stops the sweep and closes the Postgres pool. If the settler cannot start, it closes what it opened and rejects with the error that stopped it, such as the listen's `EADDRINUSE` or a configuration it refuses ([What stops the start](https://lcp.integraledger.com/guides/settler.md#what-stops-the-start)). ## Configuration `serveProfileFacilitator(config)` takes a `ProfileFacilitatorConfig`: the core's members, and one member for each module the deployment starts, named for the module. A module whose member is absent is neither loaded nor started. ### The core's members | Member | Type | Meaning | |---|---|---| | `listen` | `string` | `"host:port"`; an IPv6 host may be written in brackets. | | `store` | `{ url: string }` | The Postgres connection string. Postgres holds the record, the fee count and the modules' durable state; the settler creates its tables at start where they do not exist ([The database](https://lcp.integraledger.com/guides/settler.md#the-database)). | | `settleWaitMs` | `number` | How long `/settle` waits for the chain before it answers `settlement_pending`. A value that is not a positive finite number means 30 000. | | `credential` | `string`, optional | The credential every call must present as `Authorization: Bearer `; required where a configured module holds a key ([The credential](https://lcp.integraledger.com/guides/settler.md#the-credential)). Its characters are those RFC 6750 admits in a bearer token: letters, digits and `-._~+/`, then any `=`. | | `feeBudgets` | `{ network, amount, periodSeconds }[]`, optional | At most one per network, each on a network a configured module serves ([The fee budget](https://lcp.integraledger.com/guides/settler.md#the-fee-budget)). `amount` is in the smallest unit of the network's fee asset, a `bigint` or its decimal digits, and positive; `periodSeconds` is a positive whole number. | | `operatorLog` | `(entry, cause?) => void`, optional | Receives every entry for the operator ([Bounds and logs](https://lcp.integraledger.com/reference/settler.md#bounds-and-logs)). The default writes one JSON line per entry on standard error. | ### The database The settler needs Postgres 11 or later: nothing it runs is newer than `hashtextextended`, which Postgres 11 added. Its tests run on Postgres 18. At every start it runs `CREATE TABLE IF NOT EXISTS` and `CREATE INDEX IF NOT EXISTS` for its three tables and two indexes ([Storage](https://lcp.integraledger.com/reference/settler.md#storage)), so the role in `store.url` needs `CREATE` on the schema they live in and owns them. From Postgres 15, the schema `public` grants `CREATE` to no role but its owner by default: grant it, or create a schema named for the role and owned by it, which Postgres's default `search_path` (`"$user", public`) puts first. The role then reads and writes only those tables, and takes transaction-level advisory locks. Each process holds at most 10 connections. Every settler process that may settle the same payments uses the same database: the record is what keeps one payment submitted once and answered success once. Do not truncate or replace its tables while payments they hold can still land, and back them up as you back up payment records. ### The modules Each module's member lists the networks it serves. Its keys reach it inside that member, as the signer objects its classes take; the settler reads no key material of its own. A network is the CAIP-2 id lcp's type for the chain names, and the table gives the ones each module takes. | Member | Chain | Networks | Scheme: pairings (`confirmed`) | `extra.key` | `extra.acceptsZero` | Facilitator | |---|---|---|---|---|---|---| | `algorand` | Algorand | `algorand:` | `exact`: `x402/exact/algorand` (yes) | `fee-payer` | `x402/exact/algorand` | `@x402/avm`'s class; the settler's own path for a rekeyed payer signing with one key and a Falcon-key payer | | `aptos` | Aptos | `aptos:` | `exact`: `x402/exact/aptos` (yes) | `fee-payer`, or `none` with `sponsor: false` | `[]` | `@x402/aptos`'s class | | `cardano` | Cardano | `cardano:mainnet`, `cardano:preprod`, `cardano:preview` | `exact`: `x402/exact/cardano` (yes), `x402/exact/cardano/lock` (yes) | `none` | `[]` | `@x402/cardano`'s class | | `casper` | Casper | `casper:casper-test` | `exact`: `x402/exact/casper` (no) | `relayer` | `[]` | `@x402/casper`'s class | | `concordium` | Concordium | `ccd:` | `exact`: `x402/exact/ccd` (no) | `fee-payer` | `x402/exact/ccd` | `@x402/concordium`'s class | | `evm` | EVM | `eip155:` | `exact`: `x402/exact/eip155/eip3009` (yes), `x402/exact/eip155/permit2` (yes); `upto`: `x402/upto/eip155/permit2` (yes); `auth-capture`: `x402/auth-capture/eip155/eip3009` (yes), `x402/auth-capture/eip155/permit2` (yes); `batch-settlement`: `x402/batch-settlement/eip155` (yes) | `relayer` | `x402/exact/eip155/eip3009` on `exact`; `[]` on the others | `@x402/evm`'s classes | | `erc7710` | EVM | `eip155:`, where `evm` registers `exact` | `exact` with `erc7710`: `x402/exact/eip155/erc7710` (yes), `x402/exact/eip155/erc7710-salt` (yes) | `relayer` | `[]` | the settler's own, behind the `evm` module's `exact` | | `hedera` | Hedera | `hedera:mainnet`, `hedera:testnet`, `hedera:previewnet`, `hedera:devnet` | `exact`: `x402/exact/hedera` (yes) | `fee-payer` | `[]` | `@x402/hedera`'s class | | `lnbtc` | Lightning | `lnbtc:000000000019d6689c085ae165831e93`, `lnbtc:000000000933ea01ad0ee984209779ba` | `exact`: `x402/exact/lnbtc/payment-hash` (yes) | `none` | `[]` | the settler's own | | `near` | NEAR | `near:mainnet`, `near:testnet` | `exact`: `x402/exact/near` (yes) | `relayer` | `[]` | `@x402/near`'s class | | `polkadot` | Polkadot Asset Hub | `polkadot:68d56f15f85d3136970ec16946040bc1`, `polkadot:67f9723393ef76214df0118c34bbbd3d` | `exact`: `x402/exact/polkadot/lcp-assets-remark` (yes) | `none` | `[]` | the settler's own | | `solana` | Solana | `solana:`; `upto` and `batch-settlement` not on `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | `exact`: `x402/exact/solana` (yes); `upto`: `x402/upto/solana` (no); `batch-settlement`: `x402/batch-settlement/solana` (no) | `fee-payer` | `x402/exact/solana` on `exact`; `[]` on the others | `@x402/svm`'s classes | | `starknet` | Starknet | `starknet:SN_MAIN`, `starknet:SN_SEPOLIA` | `exact`: `x402/exact/starknet` (yes) | `relayer` | `x402/exact/starknet` on `starknet:SN_SEPOLIA`; `[]` on `starknet:SN_MAIN` | the settler's own | | `stellar` | Stellar | `stellar:pubnet`, `stellar:testnet` | `exact` with `lcp-precondition`: `x402/exact/stellar/precondition` (yes) | `relayer` | `x402/exact/stellar/precondition` | the settler's own | | `sui` | Sui | `sui:mainnet`, `sui:testnet`, `sui:devnet` | `exact`: `x402/exact/sui` (yes) | `none` | `x402/exact/sui` | the settler's own | | `ton` | TON | `tvm:-239`, `tvm:-3` | `exact`: `x402/exact/tvm` (yes) | `relayer` | `x402/exact/tvm` | `@x402/tvm`'s class | | `tron` | Tron | `tron:` | `exact`: `x402/exact/tron/lcp-trc20-memo` (yes) | `none` | `[]` | the settler's own | | `xrpl` | XRP Ledger | `xrpl:` | `exact`: `x402/exact/xrpl` (yes); `upto`: `x402/upto/xrpl` (yes) | `none` | `[]` | `@x402/xrpl`'s class for a payer signing with one key; the settler's own for a multisigned payer and for `upto` | `confirmed` is lcp's registry's: whether something outside lcp has shown the form as its profile defines it ([the pairing registry](https://lcp.integraledger.com/reference/pairings.md)). The settler serves the forms marked `no` as their profiles define them, but no recorded run outside lcp has yet shown one. The `casper` and `concordium` modules serve only such forms: run them on a test network, and do not offer those forms to buyers until the registry says `yes`. Each member, one entry per network unless it says otherwise: - **`algorand`**: `network`; `signer`, the seller's fee payer as `@x402/avm`'s class takes it (`FacilitatorAvmSigner`), with its algod node; `indexer`, the seller's Indexer, which lcp's read uses; `archival`, optional, true where that Indexer holds every round. The fee payer pools the group's fee by its own zero-amount payment in the same atomic group. The class signs every entry of the group that one of the key's addresses sends, so a group may hold one such entry, and only where the option's `extra.feePayer` names its sender: a group with two, or with one the option's `extra.feePayer` does not name, is refused `invalid_exact_avm_invalid_fee_payer`; with no `extra.feePayer` the buyer pays its own fee. An entry a logic signature authorises, and one that names `asnd`, are refused before anything moves. - **`aptos`**: `network`; `signer`, the seller's account (`FacilitatorAptosSigner`); `sponsor`, optional, whether the key pays the payer's gas as its fee payer (default true, the class's own default); `node`, the seller's REST endpoint, its base without `/v1`. With `sponsor: false` the payer pays its own gas and the key signs nothing: the kind states `extra.key` `none` and `/supported` names no signer for it, and an option that names an `extra.feePayer` is refused `invalid_payment_requirements` before the class is asked, since the class pays the gas of any payment whose option names one of the key's addresses. - **`cardano`**: `network`; `signer`, the chain-query object `@x402/cardano`'s class takes over the seller's provider (a provider's project id is its configuration, not a key); `reader`, lcp's `CardanoReader` over the seller's indexer. The class broadcasts the transaction the buyer signed, whose fee the buyer pays. `@x402/cardano` 2.31.0 reads a transaction's confirmations from Blockfrost alone: over Koios alone it sees none, so an option it settles there states `extra.confirmationPolicy` as `{ "l1Confirmations": 0 }`, and an option that states none, whose default asks one confirmation, is refused at `/verify`. A provider with a Blockfrost project serves an option that asks confirmations. `/settle` answers success where the class does, and otherwise once lcp's read through `reader` shows the transaction final, at the ledger's security parameter of confirmations (2160 on mainnet and Preprod, some 12 hours); until then it answers `settlement_pending` naming the transaction. Over Koios alone the class's settle gives no success, so a payment is answered at that mark. Its guard against broadcasting one transaction twice is kept in the settler's database, so a repeat after a restart resumes observing what was broadcast. - **`casper`**: `network`, `casper:casper-test` (the settler does not start on `casper:casper`: see *What it does not serve*); `signer`, the seller's key as `@x402/casper`'s class takes it (`FacilitatorCasperSigner`, made with its `toFacilitatorCasperSigner` and an `rpcUrlConfig` that names `rpc` for the network), which sends the transaction that calls the token package's `transfer_with_authorization` with the payer's CEP-3009 authorization, and pays its gas; `rpc`, the seller's node, through which the class reads the token before it settles, lcp's read finds the payment and the fee count reads its cost. The settler does not start where the signer names another node, as `@x402/casper`'s signer does for a network its `rpcUrlConfig` leaves out, falling back to a public node, nor where its `speculativeRpcUrlConfig` names a node other than `rpc`: with one, the class's check has the key sign a deploy of the payer's authorization at every `/verify` and `/settle` and sends it there for speculative execution. `paymentMotes`, optional, is the most the transaction can pay, in motes (`@x402/casper`'s default, 2.5 CSPR, where absent), which the fee budget counts from the transaction's submission until the node shows the cost. The class refuses a zero amount. `signers` lists the key's account hash, 64 hex digits without the `00` tag a payload's address carries. The class's node calls and lcp's read carry no header of the seller's, so a node credential reaches the node only within `rpc`'s URL; and the class waits up to a minute for its transaction, its node calls without a timeout of their own, so its settle can run past `settleWaitMs`. lcp's read takes the token's used nonces from its dictionary `used_nonces`, as lcp's profile names it, where the class's check before it settles reads `authorization_state`. - **`concordium`**: `network`, the one the signer is connected to; `signer`, the seller's sponsor account and its key with its node (`FacilitatorConcordiumSigner`), which co-signs the payer's sponsored transaction and pays its energy; `reader`, lcp's `CcdReader` over the seller's node. The record names each payment by the digest of what its sender signed, so a payment is never sent twice. - **`evm`**: `network`; `rpc`, the seller's JSON-RPC endpoint, which lcp's reads and the fee's read go through; `signer`, the seller's gas key (`FacilitatorEvmSigner`, made with `toFacilitatorEvmSigner` over the same node); `schemes`, optional, the schemes registered (`exact`, `upto`, `auth-capture`, `batch-settlement`; all four where absent); `eip6492AllowedFactories`, optional, the ERC-6492 factories `exact` and `batch-settlement` may call to deploy a payer's wallet (none where absent); `authCapture`, optional, `auth-capture`'s own configuration, passed to its class unchanged. Before the class is asked, `exact` refuses an option that pays several payees (a non-empty `extra.splits`) and Circle's batched option (`extra.name` `GatewayWalletBatched`, or an `extra.verifyingContract` other than the asset), which no published EVM class settles. At `/settle`, `upto` settles the amount its requirements state, the charge: requirements that are the option the payment accepted in every member but an `amount` at or below the accepted one are held as that option, and the class checks the permit against the accepted maximum, as its own settle does; any other requirements are refused `invalid_payload`. `exact`'s `extra.acceptsZero` names `x402/exact/eip155/eip3009` alone, and every other kind's is `[]`. On Base Sepolia, USDC's EIP-3009 `transferWithAuthorization` of 0 succeeds, emitting `AuthorizationUsed` and a `Transfer` of 0 (`eth_simulateV1` at block 61198157); at block 61194449, x402's `exact` and `upto` Permit2 proxies revert `InvalidAmount` and the commerce-payments escrow's `authorize` reverts `ZeroAmount`; batch settlement's facilitator requires a deposit above 0. - **`erc7710`**: `network`; `rpc`; `signer`, the seller's gas key, whose node must answer `eth_simulateV1`. The key sends from its first address, so that address is the delegate the leaf delegation must name (or the reference implementation's wildcard delegate), and the account the simulation runs from. It registers nothing of its own: on each of its networks it is offered to the `evm` module's `exact` registration, which hands it every payment whose option names `erc7710`. The settler does not start where the `evm` module does not register `exact` on such a network. It simulates the redemption the payment names, then calls `redeemDelegations` on the delegation manager the payload names, with one execution that transfers the option's amount to `payTo`. - **`hedera`**: `network`; `signer`, the seller's fee-payer account and its key (`FacilitatorHederaSigner`): the class takes only a payment whose transaction id names an account it manages as `extra.feePayer`; `mirror`, the seller's Mirror Node REST base URL, which lcp's read and the fee count use; `archival`, optional, true where it holds every record since the network began. `@x402/hedera` 2.31.0 makes the signer from its parts rather than from a key alone: `toFacilitatorHederaSigner` over `signAndSubmitTransaction` from `createHederaSignAndSubmitTransaction` (a client per network, such as `createHederaClient`'s, and the fee payer's `PrivateKey`), `verifyPayerSignature` from `createHederaVerifyPayerSignature`, and `preflightTransfer` from `createHederaPreflightTransfer`. - **`lnbtc`**: `network`, x402's `lnbtc` id of Bitcoin mainnet (`lnbtc:000000000019d6689c085ae165831e93`) or testnet3 (`lnbtc:000000000933ea01ad0ee984209779ba`). The buyer's node paid the invoice before the preimage reached the buyer, so settling moves nothing: the module makes the scheme's validation through lcp's `validateExactLnbtc`, answers the invoice's payment hash as the transaction, names no payer, and reads nothing. x402's scheme forbids `/verify` for this flow, so `/verify` answers `unsupported_scheme`; `/settle` makes the validation before the record's claim. - **`near`**: `network`; `signer`, the seller's relayer account and key with its RPC node (`FacilitatorNearSigner`), which wraps the payer's NEP-366 delegate action in a transaction of its own and pays its gas and one-yoctoNEAR deposit; `rpc`, the seller's RPC node. - **`polkadot`**: `network`, `polkadot:68d56f15f85d3136970ec16946040bc1` (Polkadot Asset Hub) or `polkadot:67f9723393ef76214df0118c34bbbd3d` (Westend Asset Hub); `rpc`, an HTTP JSON-RPC endpoint. The payer signs and pays every fee. A node that keeps the state of every block (an archive node) gives the events of any block; a pruning node discards the state of older blocks, and a block that holds the extrinsic and whose state is discarded keeps the answer `settlement_pending`. The runtime metadata is loaded on the first payment for the network, and again whenever the node's runtime version changes. A success names `-`; a pending answer names the extrinsic's hash. The kind's `extra.acceptsZero` is `[]`: lcp's option filter takes a positive amount only (its profile's rule 1), and a `transfer_keep_alive` of 0, dry-run on Westend Asset Hub at block 19635446, dispatches and emits no event. - **`solana`**: `network`; `node`, the seller's JSON-RPC endpoint, one whose `getFirstAvailableBlock` is at or below the slot at which each payment was issued; `signer`, the seller's fee payer (`FacilitatorSvmSigner`), which co-signs every transaction the payer signed and, on the channel forms, pays the channel's rent; `transactionVersions`, optional, the message versions the classes accept (their default `[0, 1]`). `upto` and `batch-settlement` need the payment-channels program, which is deployed on devnet and testnet and not on mainnet: on Solana mainnet (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`) only `exact` is registered. Their channels are kept in the settler's database. `upto` is settled in the order x402's `upto` resource server sends it: `/verify` of the opening as the buyer sent it, then `/settle` of its deposit before the resource server's handler runs and of its claim after, each carrying the `type` (`deposit`, `claim`) that server adds. A claim needs the voucher of the option's `extra.receiverAuthorizer`, which the module does not sign: the resource server signs it with its own key. - **`starknet`**: an object `{ networks }`, one entry per network: `network`; `rpc`, a JSON-RPC node (specification 0.9 or later) that serves `starknet_traceTransaction` and `starknet_simulateTransactions`; `executor`, an `address` and its `signer`, the account the payer's outside execution names as its caller, stated as `extra.feePayer`, which sends and pays for the transaction that executes it; `maxFee`, optional, the most one settlement's resource bounds may pay, in fri; `skewMarginSeconds` (default 60) and `minSettleMarginSeconds` (default 30), optional, the scheme's margins. x402 specifies Starknet and publishes no code for it, so the module is written to x402's scheme text and lcp's profile. On `starknet:SN_SEPOLIA` the kind's `extra.acceptsZero` names `x402/exact/starknet`, and an option of amount `"0"` is taken on STRK (`0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d`) and USDC (`0x53b40a647cedfca6ca84f542a0fe36736031905a9639a7f19a3c1e66bfd5080`), the tokens on which lcp's `starknetFloor` answers 0 (its profile's rule 24): a `transfer` of 0 of each, simulated on Starknet Sepolia at block 18422698, emits a `Transfer` of 0. lcp refuses `"0"` on any other token, `starknet/option-malformed`, which the module answers `invalid_payment_requirements`. On `starknet:SN_MAIN` the list is `[]`. - **`stellar`**: an object `{ networks }`: `network`; `rpc`, a Stellar RPC endpoint that holds the history the read searches; `source`, the seller's funded account as a signer (`address` and `signTransaction`, such as x402's `createEd25519Signer` of `@x402/stellar` or a SEP-43 wallet), the transaction's source, which pays its fee; `maxTransactionFeeStroops`, optional (default 50,000), and `inclusionFeeStroops`, optional (at least 100, default 100). It serves the agreement form, the option whose `extra.assetTransferMethod` is `lcp-precondition`: the module builds the transaction around the buyer's operation and preconditions, unchanged, signs it as its source, and carries the buyer's payload signature with its own. - **`sui`**: an object `{ networks }`: `network` (`sui:mainnet`, `sui:testnet` or `sui:devnet`); `graphql`, the seller's GraphQL endpoint. It serves the path where the buyer pays gas and the gasless path (`extra.gasless`), and holds no key. A transaction the buyer already executed is judged at `/verify` by its effects, and not refused for having executed; its `/settle` answers a failure naming it. The kind's `extra.acceptsZero` names `x402/exact/sui`: a transfer of 0 executes where the buyer pays gas (Sui testnet transaction `7EjfN1kqGng3phZjqgCzy8RRRXCP2Ybt7mikGgjBUwKA`, status `SUCCESS`, its only balance change the sender's gas), and at 0 the signed transfer must name the option's payee. lcp's option filter refuses 0 on the gasless path. - **`ton`**: `network`; `signer`, the seller's highload-v3 wallet and its node (`FacilitatorTvmSigner`), which relays the payer's W5 request in a message of its own and pays its gas; `reader`, lcp's `TvmReader` over the seller's TON Center v3 index. - **`tron`**: `network`, `tron:`; `fullNode` and `solidityNode`, the base URLs of a FullNode that keeps the block history (not a lite FullNode) and of a Solidity node, with java-tron's HTTP API. The payer signs and pays every fee. - **`xrpl`**: `network`; `node`, the seller's rippled or Clio JSON-RPC endpoint, holding the ledgers from each payment's issue to the validated ledger; `waitMs`, optional, how long a settle waits for its transaction in a validated ledger (default 30 000); `maxFeeDrops`, optional, the most fee a payment may sign (the class's default, 10 000). Both paths refuse a payment that names a `Delegate` or carries `Memos`, as x402's scheme requires. For `upto`, the payer opens a payment channel to `payTo` and signs one claim off the ledger; at `/settle` the resource server adds `settlementTransaction`, a `PaymentChannelClaim` its `payTo` key signed for the actual charge with `tfClose`, which the module checks and submits unchanged; `/verify` refuses a payload that already carries one, as the scheme requires. The `cardano`, `concordium` and `ton` modules take an lcp reader in `reader` rather than a node's URL, and lcp ships the interface but no implementation: `CardanoReader` of `@integraledger/lcp/cardano`, `CcdReader` of `@integraledger/lcp/ccd` and `TvmReader` of `@integraledger/lcp/tvm`, each documented member by member on its API page ([`cardano`](https://lcp.integraledger.com/reference/api/cardano.md), [`ccd`](https://lcp.integraledger.com/reference/api/ccd.md), [`tvm`](https://lcp.integraledger.com/reference/api/tvm.md)), with the calls each makes in [Rails: reading settlement](https://lcp.integraledger.com/guides/rails.md#reading-settlement). Write one over your own indexer or node. Its `network` is the module's `network`: the module refuses to start where they differ. Each call is read-only and bounded by your own timeout and byte limit, and rejects on any failure, with lcp's `ReaderError` (`@integraledger/lcp/evm`) where the kind is known: a rejection reads as `unreadable`, never as absence. An item the endpoint does not hold is answered only in the form the interface names for it (`null`, or `{ notFound: true, ... }` with the point the interface asks for), and only where the endpoint answered in the form it documents for a missing item. lcp makes no other call, so the endpoint, its credentials, its timeouts and its retries are yours. ### What stops the start `serveProfileFacilitator` rejects with the first of these it meets, in this order, having closed what it opened; each message starts as shown: | The configuration | The message | |---|---| | `listen` is not `host:port` | `listen must be "host:port"` | | `credential` holds a character RFC 6750 does not admit | `credential must be a bearer token` | | A fee budget whose amount is not a positive integer, or whose period is not a positive whole number of seconds | `the fee budget of : its amount is not a positive integer`, `the fee budget of : its period is not a positive number of seconds` | | Two fee budgets on one network | ` has two fee budgets` | | Postgres cannot be reached, or the tables cannot be created ([The database](https://lcp.integraledger.com/guides/settler.md#the-database)) | the driver's own error | | A module's member it refuses, the modules taken in the order of their names | `casper on : not served` (`casper:casper`), `casper on : the signer reads`, `casper on : the signer's speculative execution goes to`, `casper on : the signer names the chain`; `the Cardano reader serves`; `the Concordium signer and reader must serve`; `lnbtc: is not an lnbtc network`; `not a Starknet network`, `the executor's address is not an account address`; `not a Stellar network`, `the source account's address is not an account strkey`, `the fee ceiling must be positive, and the inclusion fee at least 100 stroops`; `not a Sui network`; `the TON reader serves` | | An `erc7710` network where the `evm` module does not register `exact` | `an own module is offered to exact on , which no module registers` | | A module's class that states `pairings`, `key`, `acceptsZero` or `feeBudget` in its `extra` | `: a module's facilitator states` | | Two registrations of one scheme on one network | `two registrations of ` | | Two modules behind one registration whose keys sign for different purposes | ` on : its modules' keys sign for` | | A fee budget on a network no module serves | `the fee budget of : no module serves it` | | A fee budget on a network where a keyed module neither counts nor shows its fees (`ton`, `concordium`) | `the fee budget of : the module's key pays fees it neither meters nor shows` | | A keyed module, and no `credential` | `a module holds a key ( on , ...): credential is required` | Any other rejection is the error of a call the start makes, such as the listen's `EADDRINUSE`. ## Keys `extra.key` states what the module's key signs, by one of three values: | `extra.key` | The key | Modules | |---|---|---| | `none` | The module holds no key and signs nothing: it submits what the payer signed, and the payer pays the fee. | `cardano`, `lnbtc`, `polkadot`, `sui`, `tron`, `xrpl`, and `aptos` with `sponsor: false` | | `relayer` | The key sends the transaction and pays its network fee. | `casper`, `erc7710`, `evm`, `near`, `starknet`, `stellar`, `ton` | | `fee-payer` | The key co-signs the payer's transaction as the account that pays its fee. | `algorand`, `aptos`, `concordium`, `hedera`, `solana` | Each chain's own name for the role (a gas key, a sponsor, a source account, an executor) stays in its module's notes above. The key is always the seller's: the operator's code makes the signer object the module's class takes and passes it in the configuration, and its address is in `/supported`'s `signers`. One kind states one purpose: two modules behind one registration whose keys sign for different purposes are refused at start. ## The credential The resource server names the payee and the amount, and a keyed module pays a fee for whatever it submits, so an open settler would spend the seller's money on payments between other parties. A deployment with a module whose key is not `none` therefore does not start without `credential`. Every call, `GET /supported` included, must then present it as `Authorization: Bearer `; the settler compares the SHA-256 of what is presented with that of the credential in constant time, and answers a call without it `401` `{"error":"unauthorized"}` with `WWW-Authenticate: Bearer`, before it reads the body, closing the connection. A keyless deployment may set one too, with the same effect. ## Security The settler serves plain HTTP (`node:http`, no TLS option): the credential and every payment cross the network in clear unless TLS is in front of it. Bind `listen` to loopback or a private interface and terminate TLS in a proxy before it, or run the settler on the resource server's own host. The credential is its only gate: anyone who holds it can have a keyed module pay fees for payments between other parties, without limit unless a fee budget caps them ([The fee budget](https://lcp.integraledger.com/guides/settler.md#the-fee-budget)), so keep it as you keep the keys, and set a budget on each network whose fees a key pays (the `ton` and `concordium` modules take none). The keys live in the operator's process, as the signer objects passed in; the settler reads no key material itself, and names a node in an error by its origin alone. It does not check that H is the one the resource server issued, nor that the resource server has not accepted it before ([the settler](https://lcp.integraledger.com/concepts/settler.md#where-it-sits)): those checks are the resource server's. ## The fee budget A keyed module pays fees for what it submits. `feeBudgets` caps them per network: an amount of the network's fee asset, in its smallest unit, over a period of seconds. The count holds every transaction a module whose key pays the fee submitted on the network over the last period: its bound until the chain shows it included, then the fee it paid. Where the count has reached the amount: - `/verify` and `/settle` refuse a payment whose fee the module's key would pay, `fee_budget_spent`, before anything is sent. A payment whose payer pays the fee is never refused for it. - Each kind of the network states `extra.feeBudget: true`, so that a resource server learns that the settler may refuse every payment on that network for a period. The fee counted is what the chain shows. On an EVM network it is the gas used times its price and, on an OP Stack network, the L1 data fee the receipt shows (`l1Fee`); before inclusion, the gas limit times the fee cap, with the L1 data fee the network's GasPriceOracle (`getL1Fee`) gives. On Hedera it is the fee the Mirror Node shows, asked for up to five seconds after the settle answers; where the mirror shows none by then, the `maxFee` the payer signed. The `evm`, `solana`, `aptos` and `casper` modules count each transaction their key sends as it is sent, one their class does not name in its answer included: a payer's ERC-6492 wallet deployment on EVM, or a Solana or Casper transaction whose send failed. At start the settler refuses a budget on a network no configured module serves, and one on a network where a module whose key pays fees can neither show the fee of what it sent nor count it as it sends: the `ton` and `concordium` modules, whose classes and lcp's reads give no fee. Its stated costs: - A transaction is counted once it is sent (`evm`, `solana`, `aptos`, `casper`) or once its settle answers (`algorand`, `erc7710`, `hedera`, `near`), so settles that run at once on a nearly spent budget can each pass the check before the first is counted. The `starknet` and `stellar` modules count each send before it is made, one at a time per network. The `evm` module's count at the send is what its node shows then: a transaction the node does not show yet (the operator log's `fee-not-counted`, reason `not-shown`) is not counted until a later read shows it, when the class's wait for its receipt ends or when the settle answers, and one the node never shows, never mined, is not counted. - A transaction whose id is not known before it is sent is counted at its bound for the whole period, as well as at the fee it paid once included. The count can exceed what was paid; it never falls short of it. ## Call it Both `POST /verify` and `POST /settle` take x402's facilitator request, `{x402Version: 2, paymentPayload, paymentRequirements}`, with `paymentPayload.x402Version` 2. A refusal answers `200` with the refusal in its body. ```ts no-check title="verify.ts" import { serveProfileFacilitator } from "@integraledger/profile-facilitator"; const settler = await serveProfileFacilitator({ listen: "127.0.0.1:4022", store: { url: process.env.DATABASE_URL ?? "postgres://postgres@127.0.0.1:5432/postgres" }, settleWaitMs: 30_000, tron: [{ network: "tron:728126428", fullNode: "http://127.0.0.1:8090", solidityNode: "http://127.0.0.1:8091" }], }); const requirements = { scheme: "exact", amount: "10000", asset: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", payTo: "TCwX1UeSkVfu43HD5xNMmFqDR2Xgjdxihx", maxTimeoutSeconds: 60, extra: { assetTransferMethod: "lcp-trc20-memo" }, }; // The first network is configured, and its payload is not a Tron transaction; the second is not configured. for (const network of ["tron:728126428", "tron:3448148188"]) { const body = { x402Version: 2, paymentPayload: { x402Version: 2, payload: { transaction: "0a02" } }, paymentRequirements: { ...requirements, network }, }; for (const path of ["/verify", "/settle"]) { const res = await fetch(`http://127.0.0.1:4022${path}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body), }); console.log(path, res.status, JSON.stringify(await res.json())); } } await settler.close(); ``` ```text /verify 200 {"isValid":false,"invalidReason":"invalid_payload"} /settle 200 {"success":false,"errorReason":"invalid_payload","transaction":"","network":"tron:728126428"} /verify 200 {"isValid":false,"invalidReason":"invalid_network"} /settle 200 {"success":false,"errorReason":"invalid_network","transaction":"","network":"tron:3448148188"} ``` Every check `/verify` and `/settle` make, in order, is in [the reference](https://lcp.integraledger.com/reference/settler.md). ## Pending and repeated settles When the wait ends first, `/settle` answers `{success: false, errorReason: "settlement_pending", transaction}`; x402 requires that `transaction` not be empty. Call `/settle` again with the same request: it reads the chain from where the last read stopped, sends nothing it sent before unless its single-use value is shown unconsumed and its validity open, and returns the final answer once there is one. A payment is answered success once: every later `/settle` of it answers `invalid_transaction_state` naming the transaction, as x402's `exact` family requires of a consumed payment. What each kind of repeat answers is in [the reference](https://lcp.integraledger.com/reference/settler.md#the-record-and-what-a-repeat-answers). ## What it does not serve - **MPP.** The settler answers x402's facilitator calls only, and serves none of MPP's calls. - **Sui's sponsored path.** x402's Sui scheme needs a gas station, whose wire its scheme does not state and whose caller is the buyer's client, which does not hold the resource server's credential. An option that names one is refused `invalid_payment_requirements`; the `sui` module holds no key. - **Hedera's transfer executor** (`x402/exact/hedera/transfer-executor`). No member of the configuration names an executor, and x402's specification of the method admits none by default. - **Solana's channel forms on mainnet.** `x402/upto/solana` and `x402/batch-settlement/solana` need the payment-channels program, which is not deployed on Solana mainnet; there only `exact` is registered. - **Casper mainnet.** x402's Casper scheme names `casper:casper`, but no token there has yet been shown to execute `transfer_with_authorization`, so the `casper` module does not start on it; it serves `casper:casper-test`. - **lcp's x402 pairings that another party settles.** `x402/exact/eip155/gateway-batched`, Circle's batched option, which the `evm` module refuses, and `x402/batch-settlement/cloudflare`, on Cloudflare's `cloudflare:402` network, which no module serves. ## Versions 0.5.1 takes `@integraledger/lcp` `~0.6.3` as its peer dependency: install `@integraledger/lcp@~0.6.3` beside it. A later lcp minor release needs a settler release that names it. While both packages are 0.x, a minor release may change the configuration, the answers or the storage; [the CHANGELOG](https://github.com/IntegraLedger/integra-protocol/blob/main/settler/CHANGELOG.md) lists what each release changes. It needs Node.js 24.22.1 or later. ### Upgrading from 0.4.0 0.4.0 served the `tron` and `polkadot` modules alone. 0.5.0 takes `listen`, `store`, `settleWaitMs`, `operatorLog`, `tron` and `polkadot` unchanged, and needs `@integraledger/lcp` `~0.6.0` (0.4.0 took `~0.5.0`) and Node.js 24.22.1. 0.4.0 kept its record in the table `settlement`. 0.5.0 creates `instrument`, `fee` and `module_state` beside it, never reads or writes `settlement`, and does not fill `instrument` from it, so it does not know the payments 0.4.0 answered. A repeated `/settle` of one of them is judged afresh, by the module's checks and lcp's read of the chain: - **A payment 0.4.0 answered success is never answered success again.** On Tron, the module's checks refuse a transaction id the node holds in its blocks or pending pool, and an expiration already passed; on Polkadot, the node no longer answers the extrinsic valid once its nonce is used. The answer is `invalid_transaction_state` naming the transaction, stored, where lcp's read shows the payment final, and otherwise the check's refusal, with nothing stored. - **A payment 0.4.0 answered `settlement_pending` is answered the same way once its transaction is in a block, and so is never answered success by 0.5.0, though it landed.** The one exception is a Polkadot extrinsic still in the node's pool, not yet in a block, when the repeat arrives: it passes the checks, 0.5.0 claims it, the node refuses its submission as already seen, and 0.5.0 answers success once lcp's read shows it final. - **A payment 0.4.0 claimed and never sent** is new to 0.5.0, which settles it. Neither rail lets one signed payment land twice: a Tron transaction id and a Polkadot account nonce are each used once. Before you switch, call `/settle` on 0.4.0 again for each payment it left pending, until each has a final answer (its rows in `settlement` whose `answer` is null or whose `answer->>'errorReason'` is `settlement_pending`), or read those payments with lcp's `status` after the switch. Do not run 0.4.0 and 0.5.0 at once for the same payments: each keeps its own record, so each can submit a payment and answer it success. `settlement` can be dropped once no payment it holds can still land.