Skip to content
Integra Protocol
API

@integraledger/lcp/x402-batch-settlement

x402 `batch-settlement`: one ATR per channel, its hash the EVM channel configuration's `salt`, the Solana opening transaction's seller Memo instruction, or, on Cloudflare, the echoed `extensions.legalContext` of each request.

For AI agents: this page as Markdown, and llms.txt, the index of every page.

x402 batch-settlement: one ATR per channel, its hash the EVM channel configuration's salt, the Solana opening transaction's seller Memo instruction, or, on Cloudflare, the echoed extensions.legalContext of each request.

On EVM the channel id commits to the salt, and every signature signs it; on Solana the seller Memo instruction (extra.memo) sits beside x402's receiver-authorizer binding memo; on Cloudflare there is no channel.

Interfaces

BatchEvmOpen

The buyer's inputs to the build of an x402 pairing on an eip155 chain: the document (required), the option chosen from its accepts (accepted), the payer's address (from), and the current time in Unix seconds (now); the authorization's deadline is now plus the option's maxTimeoutSeconds.

Extends

Properties

PropertyTypeDescriptionInherited from
acceptedPaymentRequirements-X402Choice.accepted
authSalt`0x${string}`32 bytes the caller draws at random: the deposit authorization's salt (ERC-3009) or the deposit permit's nonce (Permit2); under an option in the scheme's refund-authorizer mode, where H is that salt or nonce, the entropy the channel salt packs.-
depositbigint--
from`0x${string}`-X402Choice.from
nownumber-X402Choice.now
payerAuthorizer`0x${string}`--
requiredPaymentRequired-X402Choice.required

BatchSvmOpen

Properties

PropertyType
acceptedPaymentRequirements
computeUnitLimit?number
computeUnitPrice?bigint
depositbigint
openSlotbigint
payerstring
payerAuthorizerstring
recentBlockhashstring
requiredPaymentRequired
saltbigint
tokenProgramstring

BatchUnsigned

Several signing requests, signed in order. complete takes one signature per request: 0x hex for eip712, base58 for solana-message and ed25519-raw.

Properties

PropertyTypeDescription
authSalt?`0x${string}`On an EVM opening, the deposit authorization's salt: the ERC-3009 deposit's nonce is erc3009DepositNonce(channelId, authSalt) and the Permit2 deposit's nonce is authSalt as a uint256. It is the caller's authSalt, or H under an option in the refund-authorizer mode, so a client holds each nonce to it without repeating the mode test. No other build gives it.
config?ChannelConfigOn an EVM opening, the channel's configuration: batchChannelId(chainId, config) is the channelId the deposit authorization and the voucher sign, chainId their domain's. It names the receiver and the authorizers the signatures grant, so a client can show them and hold the channel id to them. No other build gives it.
requestsreadonly SigningRequest[]-

Methods

complete()

complete(signatures): Refusal | BatchPaymentPayload

Parameters
ParameterType
signaturesreadonly string[]
Returns

Refusal | BatchPaymentPayload


BatchWithin

Properties

PropertyTypeDescription
acceptedPaymentRequirements-
channelConfigJsonExactly as sent at the opening.
computeUnitLimit?numberSVM refund's request_close: the Compute Budget values, 200 000 units and 1 microlamport when absent.
computeUnitPrice?bigint-
maxClaimableAmountbigint-
recentBlockhash?stringSVM refund: the blockhash of its request_close. Given, the refund carries that transaction, which x402 sends only on a retry after invalid_batch_settlement_svm_receiver_binding_unavailable.
refund?objectA refund. EVM: its amount, absent for a full refund. SVM: {}, a full refund carrying the voucher for maxClaimableAmount, the server's accepted cumulative amount, and, with recentBlockhash, a payer-signed request_close built here.
refund.amount?bigint-
requiredPaymentRequired-

ChannelConfig

Properties

PropertyTypeDescription
payer`0x${string}`-
payerAuthorizer`0x${string}`-
receiver`0x${string}`-
receiverAuthorizer`0x${string}`-
salt`0x${string}`0x and 64 hex digits.
token`0x${string}`-
withdrawDelaynumber-

ChannelMembers

Properties

PropertyType
channelobject
channel.boundWithinPromise<Refusal | `0x${string}`>
channel.kind"open" | "close" | Refusal | "within"
channel.refPromise<Refusal | { channel: string; network: string; }>
channel.untilnumber | undefined

Eip712Request

An EIP-712 request for the buyer's signer; numbers in message are decimal strings.

Properties

PropertyType
domainobject
domain.chainIdnumber
domain.namestring
domain.verifyingContract`0x${string}`
domain.version?string
messageobject
primaryTypestring
typesobject

Type Aliases

SigningRequest

SigningRequest = { kind: "eip712"; typedData: Eip712Request | ReceiveTypedData | Permit2TypedData; } | { kind: "solana-message"; message: Uint8Array<ArrayBuffer>; } | { kind: "ed25519-raw"; message: Uint8Array<ArrayBuffer>; signer: string; }

A request to the buyer's signer.

Variables

BATCH_SETTLEMENT

const BATCH_SETTLEMENT: "0x4020074e9dF2ce1deE5A9C1b5c3f541D02a10003"


batchCloudflare

const batchCloudflare: Readonly<{ advertise: X402Advertise; bound: (presented) => Promise<Refusal | `0x${string}`>; broadcaster: (presented) => Promise<Refusal | Broadcaster>; build: (c, h) => Promise<Refusal | CloudflarePaymentPayload>; claims: boolean; data: PairingData; id: "x402/batch-settlement/cloudflare"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment | ToolCallCommitment; }]; unplaced: (option) => Refusal | PaymentRequirements; }>

x402/batch-settlement/cloudflare. The payee broadcasts (broadcaster answers "payee"): Cloudflare, for the seller, verifies the agent's signed request and bills its registered identity off chain; no status reads it.


batchEvm

const batchEvm: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; bound: (presented) => Promise<Refusal | `0x${string}`>; broadcaster: (presented) => Promise<Refusal | Broadcaster>; build: (c, h) => Promise<Refusal | BatchUnsigned>; buildWithin: (w, h) => Promise<Refusal | BatchUnsigned>; channel: Readonly<{ boundWithin: (presented) => Promise<Refusal | `0x${string}`>; kind: (p) => "open" | "close" | Refusal | "within"; ref: (p) => Promise<Refusal | { channel: string; network: string; }>; until: (_p) => number | undefined; }>; claims: boolean; data: PairingData; id: "x402/batch-settlement/eip155"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; recover: (input, reader) => Promise<Refusal | `0x${string}`>; reference: (presented, option) => Promise<Refusal | BatchEvmRef>; status: (ref, reader, query) => Promise<StatusAnswer<bigint, EvmMark>>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment | ToolCallCommitment; }]; unplaced: (option) => Refusal | PaymentRequirements; }>

x402/batch-settlement/eip155. The payee broadcasts (broadcaster answers "payee" for each payment type channel.kind takes): for every payment of the channel: the seller's facilitator executes the deposit's token authorization, redeems vouchers when it claims, and executes a refund; status reads them, and channel.kind classifies each payment. A payment of any other type gets x402/not-an-opening, as bound refuses it. bound reads a deposit alone, so channel.kind reads the rest: a refund whose amount is not a positive decimal below 2^128 gets x402/payload-malformed, as channel.kind refuses it.


batchSvm

const batchSvm: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; bound: (presented) => Promise<Refusal | `0x${string}`>; broadcaster: (presented) => Promise<Refusal | Broadcaster>; build: (c, h) => Promise<Refusal | BatchUnsigned>; buildWithin: (w, _h) => Promise<Refusal | BatchUnsigned>; channel: Readonly<{ boundWithin: (_p) => Promise<Refusal | `0x${string}`>; kind: (p) => "open" | "close" | Refusal | "within"; ref: (p) => Promise<Refusal | { channel: string; network: string; }>; until: (_p) => number | undefined; }>; claims: boolean; data: PairingData; id: "x402/batch-settlement/solana"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; recover: (input, reader) => Promise<Refusal | `0x${string}`>; reference: (presented, option) => Promise<Refusal | SvmRef>; status: (ref, reader, query) => Promise<SvmStatus>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment | ToolCallCommitment; }]; unplaced: (option) => Refusal | PaymentRequirements; }>

x402/batch-settlement/solana. The payee broadcasts (broadcaster answers "payee" for each payment type channel.kind takes): for every payment of the channel: the seller's facilitator, the feePayer, co-signs and sends the deposit and top-up transactions the payer signed, redeems vouchers when it settles, and sends the refund; status reads them, and channel.kind classifies each payment. A payment of any other type gets x402/not-an-opening, as bound refuses it.


CHANNEL_CONFIG_TYPEHASH

const CHANNEL_CONFIG_TYPEHASH: "0x1c9a06ceab9b0ebbd3301dc56c9111bb6d9af421356dc9ccb3b7084c755db308"


CHANNEL_CREATED_TOPIC

const CHANNEL_CREATED_TOPIC: "0x69d8248d5566bdb2ebc4d218970710d8378a2ff9b709a999e052b71970f808fa"


DEPOSITED_TOPIC

const DEPOSITED_TOPIC: "0x6c2a09353b5e75e70d0b9778b80a413809bb235d46c211811c474b3346791d89"


ERC3009_DEPOSIT_COLLECTOR

const ERC3009_DEPOSIT_COLLECTOR: "0x4020806089470a89826cB9fB1f4059150b550004"


PERMIT2_DEPOSIT_COLLECTOR

const PERMIT2_DEPOSIT_COLLECTOR: "0x4020425FAf3B746C082C2f942b4E5159887B0005"


VOUCHER_TYPEHASH

const VOUCHER_TYPEHASH: "0x1e1bd6ff84c3e0d9029a292b212e039c0ca97ec497c55191a4a5874294609a69"

Functions

batchChannelCreated()

batchChannelCreated(log, chainId): Refusal | { channelId: `0x${string}`; config: ChannelConfig; }

The config and id of a ChannelCreated(channelId, config) log, the id recomputed from the 7-word data.

Parameters

ParameterType
logEvmLog
chainIdnumber

Returns

Refusal | { channelId: `0x${string}`; config: ChannelConfig; }


batchChannelId()

batchChannelId(chainId, c): Refusal | `0x${string}`

The channel id: the EIP-712 digest of the configuration under the x402 Batch Settlement domain.

Parameters

ParameterType
chainIdnumber
cChannelConfig

Returns

Refusal | `0x${string}`


erc3009DepositNonce()

erc3009DepositNonce(channelId, authSalt): Refusal | `0x${string}`

The EIP-3009 deposit's nonce: keccak256(abi.encode(bytes32 channelId, uint256 authSalt)). A channelId or authSalt that is not a string of 0x and 64 hex digits is evm/field-malformed.

Parameters

ParameterType
channelId`0x${string}`
authSalt`0x${string}`

Returns

Refusal | `0x${string}`

References

BatchPaymentPayload

Re-exports BatchPaymentPayload


Broadcaster

Re-exports Broadcaster


CloudflarePaymentPayload

Re-exports CloudflarePaymentPayload


EvmMark

Re-exports EvmMark


EvmQuery

Re-exports EvmQuery


X402Advertise

Re-exports X402Advertise


X402Read

Re-exports X402Read

Last updated on

On this page