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.
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.
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.
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:
ServicePaymentAuthorization
message, authorizes the AI Agent to consider a specific service fee as paid from the balance of a specified NIP-4 channel.ChannelStateUpdatePropose
and ChannelStateUpdateConfirm
messages) to reflect this payment is governed by NIP-4’s standard mechanisms.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.
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
.
The protocol supports two primary approaches for service payment, both requiring explicit authorization from the User Agent via the ServicePaymentAuthorization
message:
This model involves a direct payment for a single service instance:
skill_id
from the agent’s advertised skills, and requests a quotation for that specific skill.ServicePaymentAuthorization
message to the AI Agent. This message indicates the “direct_transaction” method and includes proof of payment (e.g., transaction hash).ServicePaymentAuthorization
and the payment proof, then delivers the requested service.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:
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).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.ServicePaymentAuthorization
(e.g., confirms the channel exists and the UA is a party) and then delivers the requested service.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.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.
ServiceQuotationRequest
(User Agent -> AI Agent)message.parts
content):
{
"type": "ServiceQuotationRequest",
"skill_id": "unique_identifier_for_the_skill", // E.g., "text-generation-xl", "image-analysis-v2", corresponding to an entry in the Agent's A2A Agent Card skills array
"request_details": { ... } // Specific parameters for the skill
}
ServiceQuotationResponse
(AI Agent -> User Agent)message.parts
content):
{
"type": "ServiceQuotationResponse",
"skill_id": "unique_identifier_for_the_skill",
"quotation_id": "unique_identifier_for_this_quotation", // Generated by AI Agent
"price": {
"amount": "100", // Amount as a string to avoid precision issues
"currency": "USD" // Or other supported currency/token identifier like "USD"
},
"payment_instructions": { // Primarily for direct payment
"method": "on_chain_transfer", // e.g., "on_chain_transfer", "lightning_invoice"
"memo_required": false // Optional: if a memo is needed for the transaction
},
"expires_at": "timestamp_unix_epoch" // Quotation validity
}
ServicePaymentAuthorization
(User Agent -> AI Agent)message.parts
content):
{
"type": "ServicePaymentAuthorization",
"quotation_id": "unique_identifier_for_this_quotation",
"payment_method": "on_chain_transfer" | "lightning_invoice" | "nip4_channel", // Specific chosen payment method. Extensible for other direct payment types.
"payment_details": {
// Conditional structure based on payment_method
// Example for "on_chain_transfer":
// "transaction_hash": "0x...",
// "network_id": "rooch_mainnet", // Optional: if specified in quotation or contextually clear
// "proof_details": { ... }
// Example for "lightning_invoice":
// "payment_hash": "sha256_hash_of_preimage",
// "preimage": "secret_preimage_if_required_for_proof", // Optional
// "invoice_id": "lnbc..." // Optional, for reconciliation
// Example for "nip4_channel":
// "channel_id": "existing_nip4_channel_id_from_NIP-4_flow",
// "authorized_amount": { "amount": "100", "currency": "USD" } // Should match quotation price
}
}
payment_method
is "on_chain_transfer"
: payment_details
must include transaction_hash
(string). Optionally, network_id
(string) if needed for disambiguation (especially if not uniquely defined in the quotation), and proof_details
(object) for any additional verification data.payment_method
is "lightning_invoice"
: payment_details
must include fields relevant for Lightning payment proof, such as payment_hash
(string). Optionally, preimage
(string) if its revelation is part of the agreed proof mechanism, and invoice_id
(string) for easier reconciliation by the AI Agent.payment_method
is "nip4_channel"
: payment_details
must include channel_id
(string, the ID of the existing NIP-4 channel to be used) and authorized_amount
(object, confirming the amount and currency from the quotation to be debited from the channel, e.g., {"amount": "100", "currency": "USD"}
).ServiceDeliveryNotification
(AI Agent -> User Agent)message.parts
content):
{
"type": "ServiceDeliveryNotification",
"quotation_id": "unique_identifier_for_this_quotation",
"status": "success", // or "failure" with an error message
"service_output": { ... } // Actual service output or a reference to it
}
PaymentReceipt
(AI Agent -> User Agent, Optional)message.parts
content):
{
"type": "PaymentReceipt",
"quotation_id": "unique_identifier_for_this_quotation", // If for single pre-payment
"payer_did": "did:example:user_agent_did",
"payee_did": "did:example:ai_agent_did",
"amount_paid": {
"amount": "100",
"currency": "USD" // Or "USD", etc.
},
"service_description": "Description of single service rendered",
"transaction_date": "timestamp_unix_epoch"
}
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
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
ServiceQuotationResponse
(e.g., "on_chain_transfer"
, "lightning_invoice"
). The User Agent must provide proof of this transaction in the ServicePaymentAuthorization
message, with payment_method
matching the chosen direct method and payment_details
appropriate for that method.payment_method: "nip4_channel"
and including the channel_id
and the authorized_amount
in the ServicePaymentAuthorization
message.The design choices in this NIP aim to provide a flexible and secure payment framework for A2A service interactions.
ServicePaymentAuthorization
message is central, ensuring explicit user consent for every service payment and the chosen method.payment_instructions
in ServiceQuotationResponse
and payment_details
in ServicePaymentAuthorization
can be adapted for various direct payment methods.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 are highly recommended and should cover:
ServiceQuotationRequest
and ServiceQuotationResponse
exchange.ServicePaymentAuthorization
using the "direct_transaction"
method, including valid payment proof.ServicePaymentAuthorization
using the "nip4_channel"
method, referencing a valid, existing NIP-4 channel.ServiceDeliveryNotification
after successful payment verification.PaymentReceipt
generation and validation.ChannelStateUpdatePropose
after service delivery when payment was authorized via "nip4_channel"
.ChannelStateUpdateConfirm
to an AI Agent’s proposal.quotation_id
)."direct_transaction"
.ServicePaymentAuthorization
referencing a non-existent or unauthorized NIP-4 channel.(Specific test vectors and scenarios to be detailed in a companion document or repository.)
A reference implementation is planned to demonstrate the protocol in action.
nonce
and timestamp
mechanisms in NIP-2 protect against replay attacks for the payment messages themselves. quotation_id
s must be unique to prevent replay of old quotations. ServicePaymentAuthorization
messages must reference unique quotation_id
s."direct_transaction"
method, AI Agents are responsible for robustly verifying the payment_details
(e.g., confirming transaction finality on the blockchain) before delivering the service.expires_at
field in ServiceQuotationResponse
is crucial.ServicePaymentAuthorization
message, when specifying payment_method: "nip4_channel"
, must be diligently verified by the AI Agent. This includes ensuring the message is authentically signed by the User Agent, the referenced channel_id
is valid and active, the User Agent is a party to that channel, and the authorized_amount
matches the quotation.nip4_channel
authorization, the AI Agent relies on the User Agent’s liveness to confirm the NIP-4 ChannelStateUpdateConfirm
. NIP-4 should define mechanisms to handle unresponsive parties.ServiceQuotationResponse
and state channel agreements.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.