PAYMENT-REQUIRED, PAYMENT-SIGNATURE, and PAYMENT-RESPONSE headers.
The prepaid-wallet API and SDK shown here are available in the published
@grantex/sdk@0.6.0, @grantex/x402@0.4.0, Python grantex==0.5.0, and Go
v0.3.0. All four versions are registry verified. TypeScript 0.6.0, Python
0.5.0, and Go v0.3.0 include bounded refresh recovery and retry hardening.
sandbox_ledger is a complete local ledger mode.
external wallet records fail closed until a custody/provider adapter verifies
funding and settlement.Payment network compatibility
The default remainsexact on grantex:prepaid. The source checkout now also
supports opt-in Base native USDC EIP-3009. Automatic Base 402/sign/retry requires
published TypeScript 0.6.0 and x402 0.4.0, both verified from clean npm
installs. Published Python 0.5.0 and Go v0.3.0 include EVM payment responses
and authenticated reconciliation, but no automatic HTTP payment wrapper. Server
deployment and funded custody/RPC provisioning remain separate requirements.
Configure baseUsdc: { scope: 'licensing:preflight' } on createX402Agent,
supply a stable idempotencyKey, and provision the server’s base_usdc custody
provider. Policies and balance are checked before a durable EVM signature is
returned. Merchants receive standard x402 fields, not a Grantex JWT, and need
no extra.grantexScope change. See Base USDC custody
for setup, funding, finality and retries. Other chains/assets, Permit2, smart
wallets and Solana remain unsupported; unconfigured custody fails closed.
Security model
Amounts are positive integer strings in the asset’s smallest unit. For a wallet
with
decimals: 6, "1250000" represents 1.25 units. Floating-point money is
not accepted.
1. Authorize the agent
Register the agent with the wallet scopes and the exact wallet resource:/v1/prepaid-wallets. The service
rejects bearer-token downgrade, a mismatched DPoP key, a revoked grant, and an
incorrect audience.
2. Create, fund, and assign wallets
The application creates a short-lived principal session after the principal has an active grant. The human-facing wallet client uses that session, not the developer API key.3. Use official x402 v2
maxTimeoutSeconds may be 1 through 300. The signed authorization binds the
wallet, assignment, agent, principal, grant, amount, asset, network, recipient,
resource URL, scope, merchant ID, purpose, project ID, cost center, and canonical
request hash. Changing any requirement makes verification fail.
The merchant controls this x402 requirement. Grantex does not trust a caller to
lower price, change the payee, or invent semantic context after the 402 response.
Issuer-side KYC, sanctions, fraud, card, MCC, geography, settlement, and dispute
controls remain separate and must also approve the transaction.
Remote resource URLs must use HTTPS. Plain HTTP is accepted only for loopback
development hosts such as localhost, 127.0.0.1, and [::1].
The DPoP access token must contain both wallet:spend and the exact
extra.grantexScope value. Assignment policy is an additional restriction; it
cannot elevate a scope omitted from the human-approved OAuth grant.
4. Handle exact payment approval
5. Reload workflow
The agent can request value but cannot approve or fund its own request:6. Principal stop controls
Direct authorization
The SDK also exposes the reservation operation when the caller is not using the x402 fetch wrapper:grantex:prepaid, the resource server must use the x402 facilitator /v1/x402/verify and
/v1/x402/settle operations. Verification is provisional: the resource server
must complete a successful settlement before starting irreversible protected
work or returning the paid result. In sandbox_ledger, settlement completes against
the durable Grantex ledger. Opt-in Base USDC instead uses the merchant’s EVM
facilitator and finalized-chain reconciliation through the configured
base_usdc adapter. Other or unconfigured external providers fail closed.
Legacy GDT utilities
issueGDT(), verifyGDT(), and x402Middleware() remain available for
standalone signed authorization context. They do not maintain a shared prepaid
balance, atomically reserve funds, or enforce a rolling cumulative limit across
processes by themselves. Do not present a standalone GDT’s spendLimit claim as
proof that cumulative spend was enforced. Use the managed prepaid-wallet flow
for that guarantee.
Failure behavior
Verification accepts only an active reservation. After settlement, the same
authorization no longer verifies, so replay cannot execute protected work a
second time. Settlement itself is idempotent and returns its original
transaction identifier to let a resource server recover after losing the
settlement response. Side-effecting resource handlers should key their own
durable result cache or transaction on the caller’s
Idempotency-Key header.
Use the same logical identifier for that header and the SDK idempotencyKey
option. The default prepaid adapter does not send that option as a header. The
opt-in Base adapter also sets HTTP Idempotency-Key and rejects a conflicting
header. Neither can recover lost business results unless the merchant persists them.
See x402 Architecture for the trust boundaries
and Agent Prepaid Wallets for the complete API
lifecycle. Agent Wallet Governance assigns
responsibility across Grantex, the runtime, issuer, principal, and merchant.