Page cover

Payment

What is x402?

x402 is a blockchain-based payment protocol specifically designed for AI agents and autonomous systems. It enables:

  1. Agent-to-Agent Payments: Direct economic interactions

  2. Microtransactions: Cost-effective small payments

  3. Automated Billing: Smart contract-based invoicing

  4. Value Attribution: Track agent-generated value

  5. Economic Autonomy: Agents manage their own finances

Payment Flow Details

Step 1: Wallet Connection

User → MetaMask Extension → Wallet Address

Platform verifies wallet signature

Session authenticated

Step 2: Network Verification

Check current network

If not Base (8453) → Prompt network switch

User approves in MetaMask

Connection established

Step 3: Balance Check

Query USDC contract on Base

Read user balance

Verify ≥ $1.00 USDC available

Display balance to user

Step 4: Transaction Construction

Contract: USDC Token (0x833589...)
Function: transfer
To: Grace Payment Processor
Amount: 1000000 (1 USDC in smallest units)
Gas Limit: Estimated automatically

Step 5: User Confirmation

MetaMask displays:
- Transaction details
- Gas fee estimate
- Total cost
User clicks "Confirm" or "Reject"

Step 6: Blockchain Processing

Transaction submitted to Base network

Included in next block (~2 seconds)

Confirmations: 1, 2, 3... (platform waits for 1)

Transaction hash returned

Step 7: Server Verification

Platform receives tx hash

Queries blockchain for transaction

Verifies: amount, recipient, sender

Validates payment signature

Approval granted

Step 8: Agent Generation

Payment confirmed

Agent configuration processed

Code generated

Saved to database

Files prepared for download

Gas Fee Optimization

Typical Costs on Base:

  • USDC Transfer: ~$0.01-0.02

  • Network Congestion: Minimal impact

  • Time of Day: No significant variance

Gas Saving Tips:

  1. Keep small ETH balance for gas

  2. Use recommended gas settings

  3. Avoid transaction spam

  4. Monitor Base network status

Transaction Security

Multi-Layer Verification:

  1. Client-Side: JavaScript validation

  2. Wallet: MetaMask approval

  3. Blockchain: Smart contract execution

  4. Server-Side: Backend verification

  5. Database: Transaction logging

Security Features:

  • No private key exposure

  • Encrypted communication

  • Rate limiting

  • Fraud detection

  • Transaction monitoring

Last updated