How It Works
Configuration
Addexecution_cost to your agent config:
Setup for Testing
1. Create a Crypto Wallet
MetaMask (Recommended):- Install MetaMask browser extension
- Create a new wallet
- Copy your wallet address (starts with
0x...)
- Install Coinbase Wallet extension
- Set up your wallet
- Copy your wallet address
2. Get Test USDC
For Base Sepolia testnet:-
Get Base Sepolia ETH (for gas fees):
- Visit Chainlink Faucet
- Connect your wallet
- Request test ETH
-
Get Base Sepolia USDC:
- The payment system will guide you through obtaining test USDC
3. Update Agent Configuration
Payment Flow
Step 1: Start a Payment Session
Step 2: Complete Payment in Browser
- Open the
browser_urlin your browser - Connect your wallet (MetaMask or Coinbase Wallet)
- Review payment details:
- Amount in USDC
- Recipient address
- Network (Base Sepolia)
- Approve and sign the transaction
- Wait for blockchain confirmation
Step 3: Verify Payment Status
Step 4: Use the Agent with Payment Token
Example Implementation
See the complete example:Payment Behavior
- Each new task requires payment when the agent is behind a paywall
- If a task returns
input_requiredstatus, no payment is needed for that interaction - Once a task completes successfully, a new payment is required for the next task
- Payment tokens are task-specific and cannot be reused
Security Considerations
- Wallet Security: Never share private keys or seed phrases
- Test Networks: Always test on Base Sepolia before mainnet
- Payment Verification: Payments are verified on-chain via blockchain signatures
- Session Expiration: Payment sessions expire after 60 seconds by default
- Token Storage: Payment tokens are JWTs with expiration times
Production Deployment
When ready for production:-
Switch to Base Mainnet:
- Use Real USDC: Ensure users have actual USDC on Base mainnet
- Update Wallet Address: Use your production wallet address
- Monitor Payments: Track incoming payments to your wallet
-
Set Appropriate Pricing: Adjust
amountbased on service value
Tips
- Start Small: Use low amounts for testing (e.g.,
$0.0001) - Clear Communication: Inform users about payment requirements upfront
- Handle Failures: Implement proper error handling for failed payments
- Session Management: Clean up expired payment sessions regularly
- User Experience: Provide clear instructions in your UI