Overview
Deploying AI agents to production requires careful configuration, security hardening, and switching from testnet to mainnet. This guide covers everything you need for a production-ready deployment.Pre-Deployment Checklist
Security Review
- All API keys stored as secrets (not in code)
- CORS configured for specific origins (not
*) - Rate limiting enabled
- Input validation on all endpoints
- Error messages don’t leak sensitive data
Network Configuration
- Switch to mainnet chain configuration
- Update USDC contract addresses
- Verify chain IDs are correct
- Test with small amounts first
Monitoring Setup
- Cloudflare Analytics enabled
- Error tracking configured
- Payment failure alerts set up
- Wallet balance monitoring
Mainnet Configuration
Switch from Testnet to Mainnet
Update your chain configuration to use production networks.Base Mainnet Configuration
Updatesrc/constants.ts:
src/constants.ts
Network Comparison
| Configuration | Base Sepolia (Testnet) | Base (Mainnet) |
|---|---|---|
| Chain ID | 84532 | 8453 |
| Network Name | base-sepolia | base |
| USDC Address | 0x036CbD53842c5426634e7929541eC2318f3dCF7e | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
| RPC URL | https://sepolia.base.org | https://mainnet.base.org |
| Explorer | sepolia.basescan.org | basescan.org |
| Test Tokens | Circle Faucet | Real USDC required |
Update All Chain References
Search your codebase for testnet references:Crossmint Wallet Configuration
Update wallet creation to use mainnet:API Keys and Secrets
Production API Keys
Crossmint Production Key
Crossmint Production Key
- Go to Crossmint Console
- Create a production project (not development)
- Generate API key with minimal required scopes:
wallets.createwallets.readwallets:messages.sign
- Store securely - you can’t view it again
OpenAI Production Key
OpenAI Production Key
- Visit OpenAI Platform
- Create API key with spending limits
- Set up usage alerts in OpenAI dashboard
Secret Management Best Practices
Security Hardening
CORS Configuration
Restrict CORS to your frontend domains only:Rate Limiting
Protect against abuse with Cloudflare WAF:wrangler.toml
Input Validation
Validate all inputs with Zod schemas:Error Handling
Never expose internal errors to users:Monitoring and Alerts
Cloudflare Analytics
- Go to Cloudflare Dashboard → Workers & Pages
- Select your Worker
- Click Metrics tab
- Monitor:
- Request rate
- Error rate
- CPU time
- Durable Object operations
Payment Monitoring
Track payment metrics in KV:Wallet Balance Alerts
Monitor wallet balances and alert when low:Error Tracking
Integrate with error tracking services:Testing Production Deployment
Test with Small Amounts
Before going live, test with minimal USDC amounts:Smoke Tests
Load Testing
Use tools likek6 to test under load:
load-test.js
Wallet Management
Wallet Recovery Process
Document how to recover wallets in case of API key loss:- Crossmint Wallets: Contact Crossmint support with project details
- Export wallet addresses: Keep a backup of all wallet addresses
- Private key wallets: Store private keys in secure vault (1Password, AWS Secrets Manager)
Backup Critical Data
Deployment Script
Create a production deployment script:deploy-production.sh
Post-Deployment
Verify Deployment
- All endpoints responding correctly
- Payment flow works end-to-end
- Monitoring dashboards showing data
- Error rates within acceptable range
Monitor for 24 Hours
- Watch error logs
- Check payment success rate
- Monitor wallet balances
- Review performance metrics
Production Checklist Summary
Complete Production Checklist
Complete Production Checklist
Configuration
- Mainnet chain IDs updated (8453 for Base)
- Mainnet USDC address updated
- Crossmint chain set to “base” (not “base-sepolia”)
- RPC URLs point to mainnet
- Explorer links updated
- Production API keys set via Wrangler secrets
- CORS restricted to production domains
- Rate limiting enabled
- Input validation on all endpoints
- Error messages sanitized
- Admin endpoints protected
- Cloudflare Analytics enabled
- Payment metrics tracking implemented
- Wallet balance monitoring set up
- Error tracking integrated (Sentry/etc)
- Alerts configured
- Smoke tests passing
- Load tests completed
- Payment flow tested with small amounts
- Error scenarios tested
- Wallet recovery process documented
- KV namespaces created
- Secrets set in Cloudflare
- Custom domain configured (optional)
- CI/CD pipeline set up (optional)
- Rollback process tested
- Runbook created
- On-call procedures documented
- Incident response plan ready
- Team trained on monitoring tools
Troubleshooting Production Issues
High error rate after deployment
High error rate after deployment
- Check Wrangler logs:
npx wrangler tail --status error - Verify all secrets are set:
npx wrangler secret list - Check KV namespace IDs match wrangler.toml
- Rollback if critical:
npx wrangler rollback <DEPLOYMENT_ID>
Payment verification failing
Payment verification failing
- Verify chain ID matches network (8453 for Base mainnet)
- Check USDC contract address is correct for mainnet
- Confirm facilitator URL is accessible
- Check wallet has USDC balance on mainnet
- Review transaction on Basescan
Wallet balance draining unexpectedly
Wallet balance draining unexpectedly
- Check recent transactions on explorer
- Review payment logs for unusual patterns
- Verify rate limiting is working
- Check for unauthorized API key usage
- Rotate API keys immediately if compromised
Durable Objects state inconsistency
Durable Objects state inconsistency
- Check DO migration ran successfully
- Review DO logs:
npx wrangler tail | grep "[Host DO]" - Verify KV data integrity
- Consider resetting specific DO instance (data loss!)
- Contact Cloudflare support for persistent issues
Next Steps
Monitor Dashboard
View real-time metrics and logs in Cloudflare Dashboard
Crossmint Console
Manage wallets and view transaction history
Base Explorer
Track on-chain transactions and wallet balances
Support
Get help from the Crossmint community