Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nhestrompia/shielded-x402/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Shielded x402 payments flow through two primary rails:- Privacy Rail - Anonymous payment construction using zero-knowledge proofs
- Credit Rail - Fast multi-chain execution via sequencer-authorized credits
High-Level Sequence
Detailed Flow
The complete protocol involves multiple participants and steps:Phase 1: Privacy Rail (Anonymous Payment Construction)
Agent builds shielded proof
The agent application uses the
ShieldedClientSDK to construct a zero-knowledge proof demonstrating ownership of a shielded note without revealing which note is being spent.Inputs:- Selected note (amount, commitment, leaf index)
- Merkle witness proving note inclusion
- Nullifier secret
- Payment amount and recipient details
- ZK proof (Groth16)
- Nullifier (prevents double-spending)
- New output commitments (merchant payment + change)
Merchant gateway verifies proof
The merchant gateway (or relayer verify path) validates:
- ZK proof is valid
- Nullifier has not been seen before
- Merkle root is current
- Payment amount matches request
Shielded settlement on-chain
The shielded payment is settled on-chain:
- Nullifier is recorded (prevents double-spend)
- Output commitments are added to the tree
- Merchant can claim their output
Test-only shortcut: In development environments,
POST /v1/admin/credit can bootstrap balances without requiring shielded settlement. This endpoint should never be exposed in production.Phase 2: Credit Rail (Fast Multi-Chain Execution)
Agent constructs intent
Using the The agent signs the canonical bytes of this intent with their private key.
MultiChainCreditClient, the agent creates an IntentV1 message:Sequencer validates and authorizes
The sequencer (
POST /v1/credit/authorize) performs validation:Signature validation:- Verify
agentSigagainstagentPubKey - Check signature scheme matches (e.g.,
ed25519-sha256-v1)
agentNoncemust be exactlycurrentNonce + 1balance >= amountMicros(sufficient funds)chainRefis in supported chains listexpiresAtis in valid range (future but not too far)
- Insert authorization record with status
ISSUED - Increment agent nonce
- Deduct amount from balance (reserved but not yet spent)
AuthorizationV1:Relayer receives authorization
The agent sends the authorization to the appropriate chain-specific relayer via
POST /v1/relay/pay:Relayer verifies authorization
Before executing, the relayer:Verification steps:
- Check
authorization.intent.chainRefmatches this relayer’s configured chain - Fetch sequencer public key for
sequencerKeyId - Verify
sequencerSigover canonical authorization bytes - Check authorization has not expired (
now < expiresAt)
- Query sequencer for existing execution of this
authId - If already executed, return cached result
Relayer executes payment
Depending on the configured payout mode:Forward mode:
- HTTP request to merchant endpoint
- Returns merchant response to agent
- Parse
merchantRequest.bodyBase64for recipient, amount, RPC URL - Sign and send native ETH transfer transaction
- Wait for confirmation
- Return transaction hash
- Parse Solana-specific parameters (gateway program, verifier, proof)
- Construct
PayAuthorizedinstruction - Submit transaction with ZK proof verification
- Return transaction signature
- Generate synthetic deterministic hash
- No actual on-chain transaction
Relayer reports execution
The relayer constructs a signed execution report:This is posted to
POST /v1/credit/executions on the sequencer.Sequencer records execution
The sequencer:
- Verifies
reportSigagainst registered relayer public key - Checks
(chainRef, relayerKeyId)match inrelayer_keystable - Updates authorization status from
ISSUEDtoEXECUTED - Records execution details in
executionstable - Marks as idempotent (subsequent reports for same
authIdare rejected)
Phase 3: Audit Path (Verifiability)
Sequencer builds commitment epoch
Hourly (or per configured interval), the sequencer:
- Collects all authorizations since last epoch
- Computes authorization leaf hashes:
- Builds Merkle tree and computes root
Post commitment root to Base
If Base posting is enabled, the sequencer submits a transaction to This creates a permanent on-chain audit checkpoint.
CommitmentRegistryV1:Agents fetch inclusion proofs
Any agent can request a Merkle proof for their authorization:Response includes:
epochId- Which epoch includes this authorizationleafHash- The computed leaf hashsiblings- Merkle path siblingsindex- Position in the tree
Status State Machine
Authorizations move through a strict state machine: Terminal states:EXECUTED, RECLAIMED
Reclaim rules:
- Caller must be agent or sequencer
- Authorization must be in
ISSUEDstatus - Current time must be after
expiresAt - One-time transition (recorded with
reclaimed_attimestamp) - Amount is refunded to agent balance
Frozen Domain Tags
To ensure cryptographic stability, the protocol uses frozen domain tags for all signed messages:x402:intent:v1- Agent intent signaturesx402:authorization:v1- Sequencer authorization signaturesx402:authleaf:v1- Authorization leaf hashing for Merkle treex402:execution-report:v1- Relayer execution report signatures
These domain tags are frozen and will never change. Protocol upgrades will use new tags (e.g.,
v2) rather than modifying existing ones.Integration Modes
The SDK supports two primary integration patterns:1. Direct x402 Header Mode (Merchant-facing)
UsecreateShieldedFetch() for automatic 402 handling:
- SDK sends GET request
- Merchant returns
402 PAYMENT-REQUIREDwith payment details - SDK automatically builds
PAYMENT-SIGNATUREheader - SDK retries request with payment proof
- Merchant validates and returns protected resource
2. Relayer-Executed Mode (Agent-facing)
UseMultiChainCreditClient + relayer for proxy execution:
- Agent SDK requests authorization from sequencer
- Agent sends authorization + merchant request to relayer
- Relayer executes payment and calls merchant
- Relayer returns merchant response to agent
Header mode is for direct x402 compatibility with merchant APIs. Relayer mode is for pay-and-proxy execution where the relayer acts as an intermediary.
Next Steps
Credit System
Deep dive into credit authorization and sequencer invariants
Shielded Payments
Learn how zero-knowledge proofs enable private payments