|
| 1 | +.. include:: ../../../variables.rst |
| 2 | +.. _x402-integration: |
| 3 | + |
| 4 | +================ |
| 5 | +X402 Integration |
| 6 | +================ |
| 7 | + |
| 8 | +X402 is an open payment protocol that revives the long-dormant HTTP 402 "Payment Required" status code. It is designed to embed payments directly into the standard internet request-response cycle, eliminating the need for traditional sign-ups, subscriptions, or complex API keys. |
| 9 | + |
| 10 | +- **HTTP Native:** When a client (a human user, a developer's application, or an AI agent) requests a resource (like an API call or a piece of data), the server can respond with 402 Payment Required, specifying the exact price and payment details. |
| 11 | +- **Frictionless micropayments:** The client then automatically sends a payment proof (typically a signed message) and instantly gains access to the resource. This allows for pay-per-use billing in denominations as low as fractions of a cent, which is essential for AI agent commerce where machines need to pay autonomously for data and compute. |
| 12 | +- **Chain-agnostic:** X402 is a standard that works across multiple blockchain networks for settlement. |
| 13 | + |
| 14 | +X402 on Concordium |
| 15 | +=================== |
| 16 | + |
| 17 | +The integration of the X402 payment protocol with the Concordium blockchain establishes a new standard for digital commerce, seamlessly blending internet-native micropayments with regulatory compliance. X402 enables frictionless, pay-per-use transactions directly within the HTTP framework—ideal for the emerging AI and machine-to-machine economy. Concordium provides the necessary accountability and trust through its protocol-level identity layer, ensuring that every transaction is settled on a ledger compliant with global regulations (KYC/AML) while protecting user privacy via Zero-Knowledge Proofs. This synergy delivers a scalable, stable, and compliant payment rail ready for high-volume enterprise and automated applications. |
| 18 | + |
| 19 | +- **Accountability with privacy:** Concordium's protocol-level ID ensures every account is tied to a verified real-world identity, which is stored off-chain by a trusted Identity Provider. This satisfies Know Your Customer (KYC) and Anti-Money Laundering (AML) requirements. |
| 20 | +- **Zero-knowledge proofs (ZKPs):** For X402 transactions, users can prove a required attribute (e.g., "I am over 18" or "I am not on a sanctions list") without revealing their actual identity data. This preserves the user's privacy while maintaining the ability to lawfully disclose identity only when required by authorities (e.g., with a court order). |
| 21 | +- **Global regulatory readiness:** It allows businesses to use X402's seamless payment rail while adhering to diverse global regulations like MiCA or local age-gating laws for content (e.g., gambling, adult content), enabling geofencing and access control. |
| 22 | + |
| 23 | + |
| 24 | +How X402 works with Concordium's Verify & Pay |
| 25 | +============================================= |
| 26 | + |
| 27 | +The process involves two main phases: Requesting Payment/Verification, and Executing Payment/Granting Access. |
| 28 | + |
| 29 | +**Phase 1: Requesting Payment and Verification** |
| 30 | + |
| 31 | +* The Client initiates the process by sending a request (Get /content) for restricted content to the x402 Middleware. |
| 32 | +* The x402 Middleware detects the content is restricted and responds with a 402 Status + payment details (amount, recipient, etc.). |
| 33 | +* The Client performs two actions in preparation for payment: |
| 34 | + |
| 35 | + * Identity Verification: The Client verifies its identity (likely generating a ZKP using Concordium's ID layer). |
| 36 | + * Send a CCD Transaction: The Client sends the actual payment transaction to the Concordium Blockchain and receives a transaction hash ($\text{txHash}$). |
| 37 | + |
| 38 | +**Phase 2: Executing Payment and Access** |
| 39 | + |
| 40 | +* The Client constructs a Payment Payload that includes the received ($\text{txHash}$). |
| 41 | +* The Client sends a second request (Get /content) back to the x402 Middleware, but this time includes the payment proof in the header X-PAYMENT: b64 payment payload. |
| 42 | +* The x402 Middleware forwards the request to the Facilitator (a service responsible for payment validation) via a /verify endpoint. |
| 43 | +* The Facilitator performs validation: |
| 44 | + |
| 45 | + * It verifies that the user's ZKP matches the requirements |
| 46 | + * It checks if the payment details in the payload match the requirements set by the service. |
| 47 | + * It sends a request to the Blockchain to getTransactionStatus(txHash) using the hash provided in the payload. |
| 48 | + * The Blockchain responds with the tx status (e.g., pending, confirmed, failed). |
| 49 | + * The Facilitator then confirms the transaction status and updates its database (DB). |
| 50 | + |
| 51 | +* Once validated, the Facilitator sends the tx details (confirmation of payment) back to the x402 Middleware. |
| 52 | +* The x402 Middleware then grants the request by returning the Requested content to the Client. |
| 53 | + |
| 54 | + |
| 55 | +Next steps: Dive deeper into Concordium and X402 |
| 56 | +================================================= |
| 57 | + |
| 58 | +Ready to explore the future of compliant, machine-to-machine commerce? We encourage you to engage with our community and continue your journey through the resources below: |
| 59 | + |
| 60 | +* 📚 Technical Documentation: |
| 61 | + |
| 62 | + * Concordium ID and Zero Knowledge Proofs: Discover how our built-in identity layer works, including the :ref:`creation and verification of Zero-Knowledge Proofs<zk-proof-index>` (ZKPs) for compliance, on the :ref:`Concordium Identity Overview page<reference-identity>`. |
| 63 | + * Protocol Level Tokens (PLTs): Understand the role and functionality of the native :ref:`Protocol Level Tokens<plts>` on Concordium and how they are used for gas, staking, and settling the X402 payments on our PLTs Economics and Usage Guide. |
| 64 | + * Read the Official X402 Documentation: As an open standard, the `X402 protocol specification <https://www.x402.org/>`_ is maintained externally. We highly recommend reviewing the original source material for core concepts like the HTTP 402 standard, the roles of the Client/Server, and the Payment Requirements payload. |
| 65 | + |
| 66 | +* 💬 Community & Support: |
| 67 | + |
| 68 | + * Discord Server: Connect directly with core developers, ask questions about integration strategy, and get real-time support from the community. Join our `Official Concordium Discord <https://discord.com/invite/buP87EBu>`_. |
| 69 | + |
| 70 | + |
0 commit comments