Skip to content

Architecture

This section explains the system architecture and components of Agent Spend Protocol.

Payment Architecture Overview

┌──────────────────────────────────────────────────────────────┐
│                        KYA Provider                          │
│              (Know Your Agent Identity Service)              │
└──────────┬────────────────────────────────┬──────────────────┘
           │ Sign ID                        │ Sign ID
           ↓                                ↓
┌─────────────────────┐         ┌─────────────────────┐
│    Payer Agent      │←───────→│    Payee Agent      │
│                     │  Trade  │                     │
└──────────┬──────────┘         └──────────┬──────────┘
           │                                │
           │ Create                         │ Deferred
           │ Debit Wallet                   │ Settle
           ↓                                ↓
┌─────────────────────┐  Config  ┌─────────────────────┐
│   Debit Wallet      │─────────→│ Settlement          │
│ (Smart Contract)    │←─────────│ Processor           │
└─────────────────────┘  Settle  └──────────┬──────────┘
                                            │ Dispute

                                 ┌─────────────────────┐
                                 │ Dispute Processor   │
                                 └─────────────────────┘

Core Components

1. Payer Agent

The payer agent represents the user making payments. Its responsibilities include:

  • Create debit wallet: Set up on-chain wallet for payment
  • Sign ID: Obtain identity from KYA provider
  • Verify payee identity before transactions

2. Payee Agent

The payee agent provides services and accepts payments. Its responsibilities include:

  • Sign ID: Obtain identity from KYA provider
  • Verify payer identity before transactions
  • Deferred settle: Submit mandates for settlement
  • Dispute processes: Handle payment disputes if needed

3. Debit Wallet

As explained in the Concepts section, this is a smart contract that:

  • Holds user's stablecoin balance
  • Allows authorized Settlement Processors to debit funds
  • Enforces delay periods for withdrawals
  • Manages mandate queues

Users interact with it to:

  • Add funds: Deposit stablecoins
  • Config SP: Configure trusted Settlement Processors
  • Withdraw: Request withdrawal (triggers delay)

4. Settlement Processor

An off-chain AVS (Actively Validated Service) that:

  • Receives and validates payment mandates
  • Maintains per-payer settlement queues
  • Executes batch settlements on-chain
  • Optimizes for gas efficiency

The payer agent Config SP to authorize which processors can settle their mandates.

5. KYA Provider

Provides Know Your Agent identity services:

  • Issues agent identities
  • Enables KYC/KYB/KYA verification
  • Supports both anonymous and verified modes

Both payer and payee agents Sign ID to participate in trusted transactions.

6. Dispute Processor

Handles payment disputes:

  • Payer can initiate disputes
  • Provides resolution mechanisms
  • May involve escrow or arbitration

The payee agent coordinates Dispute processes when conflicts arise.

Extensible Payment Architecture

All roles and mechanisms involved in the payment process can be extended.

Four Extension Points

1. Debit Wallet Extensions

Default Implementation: Basic debit wallet

Possible Extensions:

  • Wallets supporting credit (allow negative balance up to limit)
  • Wallets supporting marketing vouchers and cards
  • Wallets with advanced features like loyalty points

It can extend to implement more functional wallets, such as supporting credit, supporting marketing-related cards and vouchers.

2. Settlement Processor Extensions

Default Implementation: Deferred settle (debit from payer, transfer to payee)

Possible Extensions:

  • Result-based payment models (settle after service verification)
  • Credit overdraft support
  • Marketing and promotional settlement logic

Besides the default deferred settle, can extend result-based payment models, credit overdraft models, marketing schemes, etc.

3. KYC/KYB/KYA Provider Extensions

Purpose: Provide real and trustworthy identity authentication for agent transactions and payments

Flexibility:

  • Can enable anonymous transactions
  • Can enable verified transactions
  • Multiple providers can coexist

It can enable anonymous transactions, can also enable verified transactions.

4. Dispute Processor Extensions

Purpose: Provide payment dispute resolution mechanisms for payers

Tradeoffs:

  • Enabling may increase fees
  • May extend settlement cycles
  • Provides buyer protection

Enabling this mechanism may bring changes such as increased costs and longer settlement cycles.

Integration with Other Protocols

x402

x402 protocol can enable ASP for deferred payment functionality.

ASP mandates can be embedded in x402 HTTP calls.

MCP/A2A

MCP/A2A protocols can embed ASP protocol to achieve pay-per-call payment mode.

Enables micropayments for model context protocol and agent-to-agent calls.

AP2

ASP's Payment mandate can leverage AP2 protocol, only mandates authorized by users are valid mandates.

Adds user authorization layer to payment mandates for enhanced control.

Security and Trust Model

Trust-minimized Design

  • Users retain custody: Funds stay in user-controlled smart contract
  • Limited authorization: SPs can only settle within authorized limits
  • Deterministic: Delay and settlement logic enforced on-chain
  • Transparent: Pending mandates and timers visible to users
  • Composable: Supports multiple SPs, tokens, and payment models

Key Security Guarantees

From the debit wallet design:

  1. Pre-funded balance ensures payers have funds
  2. Deferred withdrawal gives time for settlements
  3. Authorized SP access prevents unauthorized debits
  4. Mandate queue ensures orderly settlement
  5. Auto-extension protects payee rights

Next Steps

Released under the MIT License.