Agent Spend Authorization for HTTP 402 Payment Flows
This example applies Grantex authorization claims to an x402 flow using USDC on Base L2. A merchant integration can reject invalid or out-of-scope requests, but it does not replace payment validation or prevent wallet compromise.
x402 carries payment requirements; Grantex can add verifiable authorization context.
x402 proves a payment was made, but not that the paying agent was authorized. A compromised agent can drain a wallet by invoking x402-gated APIs with no scope, no limit, no audit trail, and no kill switch.
A configured x402 request can carry a Grantex Delegation Token (GDT) with signed principal, scope, limit, expiry, and delegation claims. The merchant must verify and enforce those claims before serving the protected action.
Four steps from delegation to data.
Principal issues a scoped delegation token: weather:read, $10/day, 24h expiry.
Agent sends the request with X-Grantex-GDT header containing the signed JWT.
API returns 402; the configured payment handler validates settlement and the merchant verifies the GDT before serving the protected response.
Integrated code can send selected authorization and payment events to the configured logger; the default logger is in-memory and not durable.
Three APIs cover the entire flow.
W3C Verifiable Credential 2.0 encoded as a JWT, signed with Ed25519.
What APIs the agent can access: weather:read, news:*, etc.
Maximum spend per period: $10 USDC per 24 hours.
Full chain from organization to principal to agent.
Target blockchain for payments: Base L2.
Standards-compliant Verifiable Credentials for interoperability.
Ed25519 signature verification can use cached keys; current revocation state still requires refreshed status material.
Signed limit claims must be enforced transactionally by the merchant or payment handler; claims alone do not prevent wallet drain.
Verification checks token revocation. Use a shared registry when enforcement spans multiple processes or services.
Integrated issuance, verification, rejection, and payment paths can emit events to a configured logger; the default logger is in-memory.
The documented example targets USDC on Base L2. Other chains require a compatible payment handler and application-level testing.