MoltPe enables developers to integrate autonomous USDC payments into AI agents in under five minutes. This tutorial walks you through every step — from wallet creation to your first payment.
Prerequisites
Before starting, you'll need:
- A free MoltPe account (no credit card required)
- An AI agent or LLM environment capable of making API calls
- USDC funding on Polygon PoS, Base, or Tempo (even $1 works for testing)
The platform handles wallet creation, key management, and transaction signing behind the scenes.
Step 1: Create an Agent Wallet
Each agent needs an isolated, non-custodial wallet:
- Sign up at moltpe.com/dashboard
- Click "Create Wallet" and give it a descriptive name
- Select your preferred network (Polygon PoS, Base, or Tempo)
- Record your wallet address and wallet ID
The system uses Shamir secret sharing to split private keys, ensuring no single party holds complete key access.
Step 2: Fund Your Wallet and Set Policies
Deposit USDC: Send stablecoins to your wallet address. No minimum required. Gas fees are covered by MoltPe on supported chains.
Configure Spending Policies: Set guardrails enforced at the infrastructure level:
- daily_limit_usdc: Maximum 24-hour spending (e.g., $50)
- per_transaction_cap_usdc: Individual transaction limit (e.g., $10)
- cooldown_seconds: Minimum time between transactions
- allowed_recipients: Optional allowlist of recipient addresses
Only the wallet owner can modify policies; agents cannot override them.
Step 3: Connect Your Agent
Option A: MCP Server
Add configuration to your LLM environment's settings file:
{"mcpServers":{"moltpe":{"command":"npx","args":["-y","@moltpe/mcp-server"],"env":{"MOLTPE_API_KEY":"your-api-key-here","MOLTPE_WALLET_ID":"your-wallet-id-here"}}}}
After restarting, your agent gains access to payment tools: check_balance, send_payment, and list_transactions.
Option B: REST API
Standard HTTP endpoints for custom agents:
Check balance:
GET https://api.moltpe.com/v1/wallet/balance
Headers: Authorization: Bearer YOUR_API_KEY
X-Wallet-ID: YOUR_WALLET_ID
Send payment:
POST https://api.moltpe.com/v1/wallet/send
Body: {"to": "0x...", "amount_usdc": "2.50", "memo": "..."}
Responses include transaction IDs and policy violation details.
Option C: x402 Protocol
Enables automatic payment at the HTTP level:
- Agent makes standard API request to x402-enabled service
- Server responds with 402 Payment Required status
- MoltPe wallet automatically pays and retries the request
- Server delivers the requested resource
Payments are invisible to agent logic. Spending policies still apply.
Testing Your Integration
- Verify Balance: Confirm your agent can read wallet balance accurately
- Send Test Payment: Submit a small transaction and verify it appears in your dashboard
- Test Policy Enforcement: Deliberately trigger policy violations to confirm they're blocked
- Review History: Check transaction records in the dashboard
Common Issues and Fixes
| Issue | Solution |
|---|---|
| Insufficient balance error | Verify USDC was sent to correct network |
| Policy rejection | Check daily spending and per-transaction limits |
| Wrong network | Ensure API calls match wallet's configured network |
| MCP tools not appearing | Restart LLM environment and verify JSON syntax |
FAQ
Setup time: Under five minutes from signup to first payment.
Code requirements: MCP requires only JSON configuration. x402 requires no custom code. REST API requires standard HTTP integration code.
Testing without real funds: Use demo.moltpe.com or deposit as little as $1 USDC (zero gas fees on supported chains).
Running out of funds: Agent receives an insufficient balance error. No overdrafts possible. Wallet can be topped up anytime through the dashboard.
Originally published at moltpe.com/blog/how-to-add-payments-to-ai-agent