This guide walks through deploying a complete Shielded x402 infrastructure, including smart contracts, credit sequencer, and payment relayers.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.
Architecture Overview
A production Shielded x402 deployment consists of:- Smart Contracts - ShieldedPool, CreditChannelSettlement, CommitmentRegistryV1 (EVM)
- Credit Sequencer - Authoritative service for credit authorization
- Payment Relayers - Chain-bound services (one per chain)
- Database - PostgreSQL for sequencer state
Prerequisites
Software Requirements
- Node.js 18+ and pnpm
- PostgreSQL 14+
- Foundry (for contract deployment)
- Git
Infrastructure Requirements
- EVM RPC endpoint (Base Sepolia or mainnet)
- Solana RPC endpoint (optional, for Solana support)
- PostgreSQL database server
- Application hosting (e.g., Railway, Fly.io, AWS)
Key Material
Generate Ed25519 keys for:- Sequencer signing key
- Each relayer reporting key
- Contract deployment
- Base commitment poster (if using registry)
- EVM relayer execution (if using EVM mode)
Step 1: Clone and Install
Clone the monorepo and install dependencies:Step 2: Deploy Smart Contracts
2.1 Configure Environment
Createcontracts/.env:
2.2 Deploy Contracts
Deploy in the following order:2.3 Verify Contracts (Optional)
Step 3: Setup Database
3.1 Create Database
3.2 Run Migrations
From the monorepo root:Step 4: Configure Credit Sequencer
Createservices/credit-sequencer/.env.production:
Generate Sequencer Keys
Step 5: Configure Payment Relayers
5.1 Base Sepolia Relayer
Createservices/payment-relayer/.env.base-sepolia:
5.2 Solana Devnet Relayer (Optional)
Createservices/payment-relayer/.env.solana-devnet:
Step 6: Deploy Services
6.1 Build Applications
6.2 Deploy Sequencer
Example using Docker:6.3 Deploy Relayers
Deploy each relayer as a separate service:Step 7: Verify Deployment
7.1 Health Checks
Check sequencer:7.2 Test Credit Flow
Allocate credit to a test agent:Step 8: Monitoring & Observability
8.1 Prometheus Metrics
All services expose/metrics endpoints:
8.2 Database Monitoring
Monitor PostgreSQL:- Connection pool usage
- Query performance
- Table sizes
- Replication lag (if using replicas)
8.3 Alerting
Set up alerts for:- Service health endpoint failures
- Database connection errors
- High execution report failure rate
- Commitment epoch build failures
- Relayer balance running low (for EVM/Solana modes)
Production Checklist
Security
Security
- All private keys stored in secrets manager (not .env files)
-
SEQUENCER_ADMIN_TOKENset to strong random value -
RELAYER_CALLER_AUTH_TOKENset for all relayers -
RELAYER_ALLOWED_HOSTSconfigured for forward mode - Database credentials rotated regularly
- TLS/HTTPS enabled for all services
- Rate limiting configured (
RELAYER_RATE_LIMIT_PER_MINUTE)
Infrastructure
Infrastructure
- PostgreSQL backups configured (daily minimum)
- Database connection pooling enabled (PgBouncer)
- Services deployed with auto-restart policies
- Load balancer configured for sequencer (if needed)
- CDN/caching for static content (if applicable)
- Monitoring and alerting configured
- Log aggregation configured (e.g., Datadog, Grafana Loki)
Blockchain
Blockchain
- Contracts deployed to production networks
- Contract ownership transferred to multisig (if applicable)
- Verifier contract tested with production proofs
- RPC endpoints have sufficient rate limits/quotas
- Relayer wallets funded with native gas tokens
- Base commitment poster wallet funded
Testing
Testing
- End-to-end test with production configuration
- Load testing completed
- Failover scenarios tested
- Database migration rollback tested
- Monitoring dashboards validated
Troubleshooting
Sequencer Issues
Database connection errors:- Verify relayer public keys in
SEQUENCER_RELAYER_KEYS_JSON - Ensure keys are in correct format (hex with 0x prefix)
- Check that relayer is using matching
RELAYER_KEY_ID
Relayer Issues
Failed to verify sequencer authorization:- Verify sequencer public key in
RELAYER_SEQUENCER_KEYS_JSON - Check that sequencer is using matching
SEQUENCER_SIGNING_KEY_ID
- Check
RELAYER_EVM_PRIVATE_KEYhas sufficient gas - Verify RPC endpoint is responsive
- Check gas price estimates
- Verify payer keypair has sufficient SOL
- Check program IDs are correct for network
- Validate RPC/WebSocket endpoints
Contract Issues
ShieldedPool proof verification failures:- Ensure verifier contract matches proof system version
- Verify public inputs are correctly formatted
- Check that proof was generated for correct circuit
- Verify EIP-712 domain separator matches chain ID
- Check that both signatures are present and valid
- Ensure state totals don’t exceed escrowed amount
Next Steps
Sequencer Reference
Detailed sequencer configuration
Relayer Reference
Detailed relayer configuration
Contracts Reference
Smart contract documentation
Client SDK
Integrate with your application