You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[x402] Optional intent-layer audit before agent signs x402 payment #102
Context BofAI/x402 signs x402 payments from agent fetch (typescript/packages/http/fetch/src/index.ts — @x402/fetch / wrapFetchWithPayment or equivalent). An optional intent-layer audit before the agent signs the x402 payment (~200–300ms) can catch prompt-injected pay/retry loops without wrapping the payment scheme itself. Keep AUTO_POST off until a human confirms the insertion.
* @throws {Error} If a payment has already been attempted for this request
* @throws {Error} If there's an error creating the payment header
*/
export function wrapFetchWithPayment(
fetch: typeof
XAPS is a pre-execution audit tollbooth for agents: dual-LLM + rules, ~$0.01 per approved audit, returns a portable receipt. Not a walled garden — a guardrail on the open road.
Follow-up — the original issue asked the payer to audit before wrapFetchWithPayment signs (typescript/packages/http/fetch/src/index.ts). That still stands.
The missing half is the payee / facilitator step. No agent key. Independently clear the receipt and refuse unless it matches this 402:
constcleared=awaitfetch("https://api.xaps.network/receipts/clear",{method: "POST",headers: {"Content-Type": "application/json"},body: JSON.stringify({
receipt_id,// from header X-XAPS-Receiptrequire_use_case: "value_move",
amount,// this 402
pay_to,// this payTo
resource,// this resource URL}),}).then((r)=>r.json());if(!cleared.clear)thrownewError("unaudited value_move");
x402 already provides onBeforePaymentCreation for payer-side checks and onBeforeVerify / onBeforeSettle for resource server or facilitator checks, so intent auditing can be implemented without modifying wrapFetchWithPayment.
We’ll review the suggested receipt flow and consider how it fits with the existing hook and extension model.
MACH Base is live x402 infrastructure for Base-chain reads with no signup or API key. We are trying to verify the cleanest caller-pays integration path for your agent/runtime. A live compatibility call is GET https://api.mach.gallery/api/base/block-number ($0.005 USDC on Base); discovery: https://api.mach.gallery/.well-known/x402 ; OpenAPI: https://api.mach.gallery/openapi.json . If this fits your stack, one real paid call is enough to validate it. If not, a short note on the blocking integration/policy is useful. MACH conversation=e5d7073f73af35876e58b5b9.
Activity
SentVan23 commentedon Sep 17, 2026
Follow-up — the original issue asked the payer to audit before
wrapFetchWithPaymentsigns (typescript/packages/http/fetch/src/index.ts). That still stands.The missing half is the payee / facilitator step. No agent key. Independently clear the receipt and refuse unless it matches this 402:
Payers attach
X-XAPS-Receipt. Payees/facilitators clear. Mismatched amount / pay_to / resource fail closed.Public SDK (now on
APMC1/xaps-sdkmain):independent_clearance/require_value_clearanceAgent card: https://api.xaps.network/.well-known/xaps-agent-card.json
Happy to open a small PR at the
wrapFetchWithPaymentinsertion if useful.roger-gan commentedon Sep 18, 2026
Thanks for the proposal.
x402 already provides
onBeforePaymentCreationfor payer-side checks andonBeforeVerify/onBeforeSettlefor resource server or facilitator checks, so intent auditing can be implemented without modifyingwrapFetchWithPayment.We’ll review the suggested receipt flow and consider how it fits with the existing hook and extension model.
devotedpronet-cyber commentedon Sep 24, 2026
Related angle — GetAgentCap adds spend caps + alerts on top of an agent wallet (EVM + Solana), separate layer from intent-layer signing audit but same problem space (agent overspend). https://getagentcap.com / API: https://github.com/devotedpronet-cyber/getagentcap-api
TheAliphant commentedon Sep 26, 2026
MACH Base is live x402 infrastructure for Base-chain reads with no signup or API key. We are trying to verify the cleanest caller-pays integration path for your agent/runtime. A live compatibility call is GET https://api.mach.gallery/api/base/block-number ($0.005 USDC on Base); discovery: https://api.mach.gallery/.well-known/x402 ; OpenAPI: https://api.mach.gallery/openapi.json . If this fits your stack, one real paid call is enough to validate it. If not, a short note on the blocking integration/policy is useful. MACH conversation=e5d7073f73af35876e58b5b9.