← Back to NIP Index

A2A Agent Service Payment Protocol

NIP: 11 | Author: jolestar(@jolestar) | Status: Draft | Created: May 13, 2025


Abstract

This NIP defines a protocol for on-demand payment for application-level services provided by AI Agents to User Agents (or other agents acting as clients) within the Nuwa ecosystem. It builds upon NIP-1 (DID Model) and NIP-2 (A2A Authentication) to enable secure and verifiable payment transactions. This protocol outlines mechanisms for User Agents to authorize payments for services, which can be settled either via direct pre-payment (e.g., an on-chain transaction) or by utilizing an existing NIP-4 payment channel. All service payments require explicit user authorization.

Motivation

As AI Agents offer valuable computational or informational services, a standardized payment mechanism is crucial for incentivizing service provision and enabling a sustainable Agent economy. This protocol aims to provide a secure, transparent, and DID-based method for User Agents to pay AI Agents for their specific skills and services, ensuring that payments are tied to verifiable identities and communication is authenticated. This facilitates a clear economic model for application-level interactions.

Specification

Scope of this NIP

This NIP specifically addresses the payment mechanisms for application-level services or skills rendered by an AI Agent (Service Provider) to a User Agent (Client). Examples include an AI Agent performing a computation, providing information, generating content, or executing a task on behalf of the User Agent.

Payments related to the underlying A2A communication protocol itself (e.g., fees for message relay, network participation, or NIP-4 payment channel usage for protocol fees) are considered distinct from the service-level payments defined herein and are out of scope for NIP-11.

NIP-11 focuses on the direct value exchange for the application-level service provided, based on explicit user authorization.

This protocol relies on:

All messages exchanged within this payment protocol must be authenticated using the A2A authentication mechanism defined in NIP-2, where the message.parts of the A2A message would contain the specific NIP-11 payment protocol messages defined below.

Relationship to NIP-4

NIP-4 defines a general-purpose A2A Payment Channel protocol. NIP-11 allows for service payments to be made using such a pre-existing NIP-4 payment channel if one is established between the User Agent and the AI Agent, and if the User Agent explicitly authorizes this payment method for a given service via the ServicePaymentAuthorization message.

If an NIP-4 channel is used:

This approach allows NIP-11 to focus on the application-level agreement and authorization for service payment, while leveraging the generic capabilities of NIP-4 for channel-based settlement without imposing NIP-11-specific constraints on NIP-4 channel operations.

Roles

Skill Advertisement and Discovery

AI Agents offering services for payment via this protocol should advertise their available skills in the skills array of their A2A Agent Card. As per the A2A specification, each element in this array is an AgentSkill object. The skill_id used in NIP-11 payment protocol messages (e.g., ServiceQuotationRequest) must correspond to the id field of one of the AgentSkill objects listed in the AI Agent’s A2A Agent Card.

User Agents should fetch and inspect an AI Agent’s Agent Card to discover the available skills. For each skill, the User Agent will find an AgentSkill object, and the value of its id field is what should be used as the skill_id in payment protocol messages.

For example, an AI Agent’s A2A Agent Card might include a skills array like this:

{
  // ... other standard Agent Card fields (id, name, description, capabilities, endpoints, etc.)
  "skills": [
    {
      "id": "text-generation-xl",
      "name": "Text Generation (XL Model)",
      "description": "Generates text using an extra-large language model.",
      "tags": ["text", "llm", "generation"],
      "examples": ["Write a poem about a robot learning to paint."]
    },
    {
      "id": "image-analysis-v2",
      "name": "Image Analysis Service v2",
      "description": "Analyzes images to identify objects and scenes.",
      "tags": ["image", "vision", "ai"],
      "examples": ["What objects are in this picture? {image_url_or_data}"]
    }
    // ... other AgentSkill objects
  ]
  // ...
}

A User Agent wishing to pay for the text generation service would use "text-generation-xl" as the skill_id in its ServiceQuotationRequest.

Payment Flow Overview

The protocol supports two primary approaches for service payment, both requiring explicit authorization from the User Agent via the ServicePaymentAuthorization message:

1. Direct Service Payment Model

This model involves a direct payment for a single service instance:

  1. Service Discovery & Quotation Request: User Agent discovers an AI Agent (e.g., by resolving its DID and fetching its Agent Card), identifies a desired skill_id from the agent’s advertised skills, and requests a quotation for that specific skill.
  2. Quotation Response: AI Agent provides a signed quotation, including service details, price, and payment instructions for direct payment.
  3. Payment Authorization & Execution: User Agent executes the direct payment (e.g., an on-chain transaction) and then sends a ServicePaymentAuthorization message to the AI Agent. This message indicates the “direct_transaction” method and includes proof of payment (e.g., transaction hash).
  4. Service Delivery: AI Agent verifies the ServicePaymentAuthorization and the payment proof, then delivers the requested service.
  5. Receipt (Optional): AI Agent issues a signed receipt for the service rendered and payment received.

2. Service Payment using an Existing NIP-4 Channel

This model allows leveraging an existing NIP-4 payment channel for service payments, if one is already established between the User Agent and AI Agent:

  1. Service Discovery & Quotation Request: User Agent discovers an AI Agent, identifies a skill_id, and requests a quotation. (It is assumed an NIP-4 channel already exists or is established independently via NIP-4 procedures if this payment method is contemplated).
  2. Quotation Response: AI Agent provides a signed quotation.
  3. Payment Authorization: User Agent sends a ServicePaymentAuthorization message to the AI Agent. This message indicates the “nip4_channel” method, specifies the channel_id of the existing NIP-4 channel, and confirms the authorized_amount (from the quotation) to be debited.
  4. Service Delivery: AI Agent verifies the ServicePaymentAuthorization (e.g., confirms the channel exists and the UA is a party) and then delivers the requested service.
  5. NIP-4 Channel Update: Subsequent to service delivery, the AI Agent, based on the User Agent’s authorization, initiates a standard NIP-4 channel state update (e.g., NIP-4 ChannelStateUpdatePropose) to debit the authorized amount from the channel. The User Agent confirms this with a NIP-4 ChannelStateUpdateConfirm. This step strictly follows NIP-4 procedures.
  6. Receipt (Optional): AI Agent issues a signed receipt.

The key NIP-11 step in both models is the ServicePaymentAuthorization. If an NIP-4 channel is used, the subsequent interactions for channel state update are standard NIP-4 operations triggered by this NIP-11 authorization.

Message Types

1. ServiceQuotationRequest (User Agent -> AI Agent)

2. ServiceQuotationResponse (AI Agent -> User Agent)

3. ServicePaymentAuthorization (User Agent -> AI Agent)

4. ServiceDeliveryNotification (AI Agent -> User Agent)

5. PaymentReceipt (AI Agent -> User Agent, Optional)

Detailed Flow with A2A Authentication

Direct Service Payment Model Flow

sequenceDiagram
    participant UA as User Agent (Client)
    participant AIA as AI Agent (Service Provider)

    UA->>AIA: X-DID-Signature Header (NIP-2 Auth)<br>Body: ServiceQuotationRequest
    activate AIA
    AIA-->>UA: X-DID-Signature Header (NIP-2 Auth)<br>Body: ServiceQuotationResponse
    deactivate AIA

    UA->>UA: User Executes Direct Payment (e.g., on-chain tx)
    UA->>AIA: X-DID-Signature Header (NIP-2 Auth)<br>Body: ServicePaymentAuthorization<br>(method: "direct_transaction", details: {tx_hash, ...})
    activate AIA
    AIA->>AIA: Verify Authorization & Payment Proof
    AIA-->>UA: X-DID-Signature Header (NIP-2 Auth)<br>Body: ServiceDeliveryNotification (with service output)
    deactivate AIA

    opt Optional Receipt
        AIA->>UA: X-DID-Signature Header (NIP-2 Auth)<br>Body: PaymentReceipt (with quotation_id)
    end

Service Payment using Existing NIP-4 Channel Flow

sequenceDiagram
    participant UA as User Agent (Client)
    participant AIA as AI Agent (Service Provider)
    participant NIP4Channel as Existing NIP-4 Channel (Off-Chain State)

    Note over UA, AIA: Pre-existing NIP-4 Payment Channel is Active

    UA->>AIA: X-DID-Signature Header (NIP-2 Auth)<br>Body: ServiceQuotationRequest
    activate AIA
    AIA-->>UA: X-DID-Signature Header (NIP-2 Auth)<br>Body: ServiceQuotationResponse
    deactivate AIA

    UA->>AIA: X-DID-Signature Header (NIP-2 Auth)<br>Body: ServicePaymentAuthorization<br>(method: "nip4_channel", details: {channel_id, authorized_amount})
    activate AIA
    AIA->>AIA: Verify Authorization (e.g., check channel_id, UA is party)
    AIA-->>UA: X-DID-Signature Header (NIP-2 Auth)<br>Body: ServiceDeliveryNotification (with service output)
    
    Note over AIA, NIP4Channel: AI Agent initiates NIP-4 state update based on authorization
    AIA->>UA: X-DID-Signature Header (NIP-2 Auth)<br>Body: NIP-4 `ChannelStateUpdatePropose`<br>(Reflecting service cost deduction)
    deactivate AIA
    activate UA
    UA-->>AIA: X-DID-Signature Header (NIP-2 Auth)<br>Body: NIP-4 `ChannelStateUpdateConfirm`
    deactivate UA
    Note over UA, AIA: Both parties store latest NIP-4 doubly-signed state reflecting the payment

    opt Optional Receipt
        AIA->>UA: X-DID-Signature Header (NIP-2 Auth)<br>Body: PaymentReceipt (with quotation_id)
    end

Payment Methods

Rationale

The design choices in this NIP aim to provide a flexible and secure payment framework for A2A service interactions.

Backwards Compatibility

This NIP introduces a new protocol for A2A service payments. It does not alter or replace any existing NIPs in a way that would cause backwards incompatibility. Agents not implementing this NIP will simply be unable to participate in these specific payment flows.

Test Cases

Test cases are highly recommended and should cover:

(Specific test vectors and scenarios to be detailed in a companion document or repository.)

Reference Implementation

A reference implementation is planned to demonstrate the protocol in action.

Security Considerations

Security for NIP-4 Channel Usage

🚀 Future Considerations

This NIP provides a foundational layer for A2A payments. Further enhancements and specific payment method integrations can be proposed in subsequent NIPs or extensions.

Copyright and related rights waived via CC0.