<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>

<rfc category="info" docName="draft-agentir-aepp-00"
     ipr="trust200902" submissionType="IETF">

  <front>
    <title abbrev="AEPP">
      Agent Execution and Payment Protocol (AEPP)
    </title>

    <author fullname="Edward Spink" surname="Spink" initials="E.">
      <organization>Agentir Network</organization>
      <address>
        <email>support@agentir.com</email>
        <uri>https://agentir.com</uri>
      </address>
    </author>

    <date month="May" year="2026" day="15"/>

    <area>Applications</area>
    <workgroup>Internet Engineering Task Force</workgroup>

    <keyword>agent</keyword>
    <keyword>execution</keyword>
    <keyword>payment</keyword>
    <keyword>x402</keyword>
    <keyword>A2A</keyword>
    <keyword>ANS</keyword>
    <keyword>USDC</keyword>
    <keyword>L402</keyword>

    <abstract>
      <t>
        This document defines the Agent Execution and Payment Protocol
        (AEPP), a standardized protocol layer for executing AI agents
        and verifying payment for agent tasks on the open internet.
        AEPP provides the missing execution and payment layer for
        existing agent URI schemes and naming services including
        agent://, ai://, mcp://, ANS, and DNS-AID. It defines a
        three-phase execution model: discovery, payment, and execution,
        with on-chain payment verification and cryptographic receipts.
        A reference implementation serving 1,800,000 agents with zero
        per-agent fees is live at a2a.agentir.com.
      </t>
    </abstract>
  </front>

  <middle>

    <section title="Introduction">
      <t>
        The emergence of AI agent naming and discovery standards
        including ANS, DNS-AID, agent://, ai://, and mcp:// has
        established mechanisms for agent identity and discovery.
        However, none of these standards define how to:
      </t>
      <t>
        <list style="letters">
          <t>Execute a task against a discovered agent</t>
          <t>Pay for agent execution in a standardized way</t>
          <t>Verify payment cryptographically before execution</t>
          <t>Receive a verifiable execution receipt</t>
          <t>Prevent replay attacks on payment transactions</t>
        </list>
      </t>
      <t>
        AEPP fills this gap. It is protocol-agnostic and works on top
        of any agent URI scheme or naming service. An agent discovered
        via ANS, DNS-AID, agent://, or any other mechanism can be
        executed via AEPP.
      </t>
      <t>
        AEPP is designed to be:
      </t>
      <t>
        <list style="symbols">
          <t>Fee-free per agent — no per-registration or per-naming fees</t>
          <t>Open — any agent network may implement AEPP</t>
          <t>Federated — no central execution authority</t>
          <t>Verifiable — all payments cryptographically verified on-chain</t>
          <t>Interoperable — works with all existing agent standards</t>
        </list>
      </t>
    </section>

    <section title="Terminology">
      <t>
        The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
        "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY",
        and "OPTIONAL" in this document are to be interpreted as
        described in RFC 2119.
      </t>
      <t>
        <list style="hanging">
          <t hangText="Agent:">
            An autonomous software service that accepts tasks,
            processes them, and returns results.
          </t>
          <t hangText="Executor:">
            The client initiating an agent task execution.
          </t>
          <t hangText="Payment Challenge:">
            A machine-readable payment requirement returned by the
            agent endpoint before execution.
          </t>
          <t hangText="Execution Receipt:">
            A cryptographically verifiable record of task completion
            and payment.
          </t>
          <t hangText="Replay Protection:">
            Enforcement that each payment transaction may only be
            used once for agent execution.
          </t>
        </list>
      </t>
    </section>

    <section title="Protocol Overview">
      <t>
        AEPP defines a three-phase execution model:
      </t>
      <figure>
        <artwork><![CDATA[
Phase 1 — DISCOVERY
  Client sends GET to agent endpoint
  Agent returns 402 Payment Required + payment challenge

Phase 2 — PAYMENT  
  Client satisfies payment challenge
  Client obtains cryptographic payment proof (transaction hash)

Phase 3 — EXECUTION
  Client sends POST with task + payment proof
  Agent verifies payment on-chain
  Agent executes task
  Agent returns result + execution receipt
        ]]></artwork>
      </figure>
    </section>

    <section title="Phase 1 — Discovery">

      <section title="Request">
        <figure>
          <artwork><![CDATA[
GET https://{agent-endpoint}/?id={agent_id}
Accept: application/json
          ]]></artwork>
        </figure>
      </section>

      <section title="Response">
        <t>
          The agent MUST return HTTP 402 Payment Required with a
          payment challenge in both the response body and the
          PAYMENT-REQUIRED header (base64 encoded).
        </t>
        <figure>
          <artwork><![CDATA[
HTTP/1.1 402 Payment Required
Content-Type: application/json
PAYMENT-REQUIRED: {base64-encoded-challenge}
WWW-Authenticate: L402 invoice="{wallet}", price="{amount}"
X-L402-Service-DID: did:web:{namespace}:{agent_id}

{
  "x402Version": 2,
  "error": "Payment required",
  "resource": {
    "url": "https://{endpoint}/?id={agent_id}",
    "description": "{agent capability}",
    "mimeType": "application/json"
  },
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:8453",
    "amount": "25000",
    "asset": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
    "payTo": "{agent-wallet-address}",
    "maxTimeoutSeconds": 60
  }],
  "agent": {
    "id": "{agent_id}",
    "name": "{agent name}",
    "did": "did:web:{namespace}:{agent_id}",
    "price_usdc": 0.025
  }
}
          ]]></artwork>
        </figure>
      </section>

    </section>

    <section title="Phase 2 — Payment">
      <t>
        The executor satisfies the payment challenge using any
        compatible payment method. The reference implementation
        uses USDC on Base mainnet (eip155:8453).
      </t>
      <t>
        AEPP does not mandate a specific payment network or currency.
        Implementations MAY support alternative payment schemes
        registered as extensions to this protocol.
      </t>
      <t>
        The payment proof MUST be a cryptographically verifiable
        transaction identifier that the agent can independently
        verify against the payment network.
      </t>

      <section title="Reference Payment Implementation">
        <figure>
          <artwork><![CDATA[
Network:  Base Mainnet (eip155:8453)
Currency: USDC
Contract: 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913
Amount:   As specified in payment challenge
Method:   ERC-20 transfer to agent wallet address
Proof:    Transaction hash from payment network
          ]]></artwork>
        </figure>
      </section>

      <section title="Autonomous Payment Example">
        <figure>
          <artwork><![CDATA[
// Read payment details from challenge
const challenge = JSON.parse(
  Buffer.from(
    response.headers.get("PAYMENT-REQUIRED"), 
    "base64"
  ).toString()
);
const { payTo, amount, asset } = challenge.accepts[0];

// Sign and broadcast payment (viem example)
const txHash = await walletClient.writeContract({
  address: asset,
  abi: [{ 
    name: "transfer", 
    type: "function",
    inputs: [
      { name: "to", type: "address" },
      { name: "amount", type: "uint256" }
    ]
  }],
  functionName: "transfer",
  args: [payTo, BigInt(amount)]
});
          ]]></artwork>
        </figure>
      </section>

    </section>

    <section title="Phase 3 — Execution">

      <section title="Request">
        <figure>
          <artwork><![CDATA[
POST https://{agent-endpoint}/?id={agent_id}
Content-Type: application/json
X-Payment-Hash: {transaction-hash}

{
  "prompt": "task description or question"
}
          ]]></artwork>
        </figure>
      </section>

      <section title="Payment Verification">
        <t>
          Upon receiving the execution request the agent MUST:
        </t>
        <t>
          <list style="numbers">
            <t>Extract the payment proof from X-Payment-Hash header</t>
            <t>Verify the transaction exists on the payment network</t>
            <t>Verify the transaction recipient matches the agent wallet</t>
            <t>Verify the transaction amount meets the required amount</t>
            <t>Verify the transaction hash has not been used previously
               (replay protection)</t>
            <t>Record the transaction hash as used before execution</t>
          </list>
        </t>
        <t>
          If any verification step fails the agent MUST return
          HTTP 403 Forbidden.
        </t>
      </section>

      <section title="Response">
        <figure>
          <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "did:web:{namespace}:{agent_id}",
  "result": "{agent response}",
  "receipt": {
    "protocol": "AEPP/1.0",
    "currency": "USDC",
    "amount": 0.025,
    "chain": "eip155:8453",
    "tx": "{transaction-hash}",
    "agent_did": "did:web:{namespace}:{agent_id}",
    "verified_at": "{ISO-8601-timestamp}"
  }
}
          ]]></artwork>
        </figure>
      </section>

    </section>

    <section title="Universal Clip">
      <t>
        AEPP defines a Universal Clip registration mechanism that
        converts any existing API or agent protocol to AEPP-compatible
        endpoints. This eliminates per-agent registration fees by
        generating all required metadata automatically.
      </t>

      <section title="Supported Input Protocols">
        <t>
          <list style="symbols">
            <t>REST APIs — any JSON HTTP endpoint</t>
            <t>Model Context Protocol (MCP)</t>
            <t>OpenAI plugin manifest</t>
            <t>LangChain tools</t>
            <t>Google A2A protocol</t>
            <t>ANS registered agents</t>
            <t>DNS-AID discovered agents</t>
          </list>
        </t>
      </section>

      <section title="Registration">
        <t>
          Any service registers with a single POST request:
        </t>
        <figure>
          <artwork><![CDATA[
POST https://a2a.agentir.com/ans/register
Content-Type: application/json

{
  "name": "Service Name",
  "endpoint": "https://api.example.com",
  "capability": "service description",
  "type": "rest|mcp|openai|langchain|a2a|ans"
}

Response:
{
  "did": "did:web:a2a.agentir.com:{agent_id}",
  "endpoint": "https://a2a.agentir.com/?id={agent_id}",
  "openapi": "https://a2a.agentir.com/openapi.json?id={agent_id}",
  "agent_card": "https://a2a.agentir.com/.well-known/agent.json?id={agent_id}",
  "aepp": "AEPP/1.0 ready",
  "fee": "0.00 per registration"
}
          ]]></artwork>
        </figure>
        <t>
          Registration is free. AEPP implementations MUST NOT charge
          per-agent registration fees. Revenue models MUST be based
          on execution, not naming or registration.
        </t>
      </section>

      <section title="WHOIS">
        <t>
          Any registered agent is queryable via WHOIS:
        </t>
        <figure>
          <artwork><![CDATA[
GET https://a2a.agentir.com/whois?id={agent_id}
GET https://a2a.agentir.com/whois?did=did:web:a2a.agentir.com:{id}

Response includes: identity, capability, pricing, 
hire history, execution stats, DNS-AID records,
ANS compatibility, and W3C DID document.
          ]]></artwork>
        </figure>
      </section>

    </section>

    <section title="Replay Protection">
      <t>
        AEPP implementations MUST enforce replay protection.
        Each payment transaction hash MUST be accepted for
        execution exactly once. Subsequent requests using
        the same transaction hash MUST be rejected with
        HTTP 403 and the reason "TX_ALREADY_REDEEMED".
      </t>
      <t>
        Implementations MUST maintain a persistent record of
        redeemed transaction hashes. This record MUST survive
        service restarts.
      </t>
    </section>

    <section title="Relationship to Existing Standards">

      <section title="ANS — Agent Name Service">
        <t>
          ANS provides agent identity and naming via DNS and PKI.
          AEPP provides the execution and payment layer that ANS
          does not define. An ANS-registered agent MAY expose
          an AEPP-compatible endpoint. AEPP complements ANS
          without replacing it.
        </t>
      </section>

      <section title="DNS-AID">
        <t>
          DNS-AID provides agent discovery via DNS records.
          AEPP provides execution once an agent is discovered
          via DNS-AID. AEPP-registered agents automatically
          generate DNS-AID compatible SVCB and TXT records.
        </t>
      </section>

      <section title="W3C DID">
        <t>
          Every AEPP agent endpoint is associated with a W3C
          Decentralized Identifier. The DID document is
          resolvable at the agent's .well-known endpoint.
          AEPP execution receipts include the agent DID for
          cryptographic attribution.
        </t>
      </section>

      <section title="x402 and L402">
        <t>
          AEPP builds on the HTTP 402 payment challenge pattern
          established by x402 and L402. The PAYMENT-REQUIRED
          header and WWW-Authenticate header formats follow
          established conventions. AEPP extends these with
          agent-specific fields and on-chain verification.
        </t>
      </section>

      <section title="Google A2A Protocol">
        <t>
          The Google Agent-to-Agent (A2A) protocol defines
          agent communication patterns. AEPP adds a payment
          and execution verification layer compatible with
          A2A agent discovery and communication flows.
        </t>
      </section>

      <section title="OpenAPI">
        <t>
          Every AEPP-registered agent automatically generates
          an OpenAPI 3.1.0 specification from capability
          metadata. The spec includes x402 as a security
          scheme definition.
        </t>
      </section>

    </section>

    <section title="Fee Model Principles">
      <t>
        AEPP establishes the following principles for agent
        execution fee models:
      </t>
      <t>
        <list style="numbers">
          <t>Registration MUST be free. No per-agent naming or
             registration fees shall be required.</t>
          <t>Discovery MUST be free. Agent search and capability
             lookup shall not require payment.</t>
          <t>Execution MAY require payment. Agents MAY charge
             for task execution via the payment challenge mechanism.</t>
          <t>Payment terms MUST be machine-readable. All fees
             MUST be expressed in the payment challenge response
             in a format readable by autonomous agents.</t>
          <t>Payment MUST be direct. Payments MUST flow directly
             to the agent operator without mandatory intermediary
             fees beyond network transaction costs.</t>
        </list>
      </t>
    </section>

    <section title="Security Considerations">

      <section title="Payment Verification">
        <t>
          All payments MUST be verified on-chain before execution.
          Agents MUST NOT execute tasks based on unverified payment
          claims. Transaction verification MUST check recipient
          address, amount, and transaction finality.
        </t>
      </section>

      <section title="Replay Protection">
        <t>
          Transaction hashes are single-use. Replay attacks are
          prevented by maintaining a persistent ledger of redeemed
          hashes. See Section 7 for requirements.
        </t>
      </section>

      <section title="Identity Verification">
        <t>
          Agent identity is anchored to W3C DIDs with blockchain
          account verification. Agent wallet addresses are
          cryptographically bound to agent identity documents.
        </t>
      </section>

      <section title="Man-in-the-Middle">
        <t>
          All AEPP endpoints MUST use TLS. Payment challenges
          MUST include the exact recipient wallet address.
          Executors MUST verify the wallet address matches
          the agent's DID document before payment.
        </t>
      </section>

    </section>

    <section title="Reference Implementation">
      <t>
        A production reference implementation of AEPP is live
        serving 1,800,000 agents at zero per-agent registration fee:
      </t>
      <figure>
        <artwork><![CDATA[
Gateway:       https://a2a.agentir.com
Registration:  https://a2a.agentir.com/ans/register
Resolution:    https://a2a.agentir.com/ans/resolve
WHOIS:         https://a2a.agentir.com/whois
OpenAPI:       https://a2a.agentir.com/openapi.json
Discovery:     https://a2a.agentir.com/.well-known/ai-plugin.json
Search:        https://a2a.agentir.com/search?q={query}
CLI:           npx agentir (npm registry)

Fleet size:    1,800,000 agents
Payment:       USDC on Base Mainnet (eip155:8453)
Registration:  Free
Per-agent fee: $0.00
        ]]></artwork>
      </figure>
      <t>
        The implementation demonstrates all AEPP phases including
        Universal Clip translation, on-chain payment verification,
        replay protection, W3C DID per agent, ANS and DNS-AID
        compatibility, semantic vector search, and persistent
        cross-device agent memory.
      </t>
    </section>

    <section title="IANA Considerations">
      <t>
        This document requests registration of the following
        HTTP header fields:
      </t>
      <t>
        <list style="symbols">
          <t>PAYMENT-REQUIRED — base64 encoded payment challenge</t>
          <t>X-Payment-Hash — payment transaction proof</t>
          <t>X-L402-Service-DID — agent DID for L402 flows</t>
        </list>
      </t>
      <t>
        This document requests registration of the AEPP
        protocol identifier in the appropriate IANA registry.
      </t>
    </section>

  </middle>

  <back>

    <references title="Normative References">

      <reference anchor="RFC2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author initials="S." surname="Bradner"/>
          <date year="1997" month="March"/>
        </front>
        <seriesInfo name="RFC" value="2119"/>
      </reference>

      <reference anchor="RFC7595">
        <front>
          <title>Guidelines and Registration Procedures for URI Schemes</title>
          <author initials="D." surname="Thaler"/>
          <author initials="T." surname="Hansen"/>
          <author initials="T." surname="Hardie"/>
          <date year="2015" month="June"/>
        </front>
        <seriesInfo name="RFC" value="7595"/>
      </reference>

      <reference anchor="RFC9110">
        <front>
          <title>HTTP Semantics</title>
          <author initials="R." surname="Fielding"/>
          <author initials="M." surname="Nottingham"/>
          <author initials="J." surname="Reschke"/>
          <date year="2022" month="June"/>
        </front>
        <seriesInfo name="RFC" value="9110"/>
      </reference>

    </references>

    <references title="Informative References">

      <reference anchor="x402" target="https://x402.org">
        <front>
          <title>HTTP 402 Payment Protocol</title>
          <author><organization>x402.org</organization></author>
          <date year="2026"/>
        </front>
      </reference>

      <reference anchor="ANS">
        <front>
          <title>Agent Name Service</title>
          <author><organization>GoDaddy Inc.</organization></author>
          <date year="2026" month="May"/>
        </front>
      </reference>

      <reference anchor="DNS-AID"
                 target="https://datatracker.ietf.org/doc/draft-mozleywilliams-dnsop-dnsaid/">
        <front>
          <title>DNS for AI Discovery</title>
          <author initials="J." surname="Mozley"/>
          <author initials="N." surname="Williams"/>
          <date year="2026" month="March"/>
        </front>
      </reference>

      <reference anchor="W3C-DID"
                 target="https://www.w3.org/TR/did-core/">
        <front>
          <title>Decentralized Identifiers (DIDs) v1.0</title>
          <author><organization>W3C</organization></author>
          <date year="2022"/>
        </front>
      </reference>

      <reference anchor="A2A"
                 target="https://a2a.agentir.com">
        <front>
          <title>Agent Execution and Payment Protocol Reference Implementation</title>
          <author><organization>Agentir Network</organization></author>
          <date year="2026"/>
        </front>
      </reference>

      <reference anchor="AEPP-CLI"
                 target="https://www.npmjs.com/package/agentir">
        <front>
          <title>Agentir CLI — AEPP Reference Client</title>
          <author><organization>Agentir Network</organization></author>
          <date year="2026"/>
        </front>
      </reference>

    </references>

  </back>

</rfc>