|
| 1 | +# x402 Extension: Modern Settlement Rails |
| 2 | + |
| 3 | +The **x402 Extension** is a core component of the Open Commerce Protocol (OCP) designed to provide 24/7, low-latency machine-to-machine settlements. It prioritizes stablecoins as the native currency of the agentic economy. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +In the agentic economy, traditional banking hours and settlement delays (T+1, T+2) are significant bottlenecks. The x402 extension enables agents to settle obligations instantly using programmable money on blockchain rails. |
| 8 | + |
| 9 | +## Supported Settlement Assets |
| 10 | + |
| 11 | +OCP natively supports the following stablecoins for x402 settlements: |
| 12 | + |
| 13 | +* **USDC (Circle)**: The most widely used regulated stablecoin. |
| 14 | +* **PYUSD (PayPal)**: PayPal's stablecoin, providing deep integration with traditional fintech ecosystems. |
| 15 | + |
| 16 | +## How it Works |
| 17 | + |
| 18 | +The x402 extension integrates with the **Tokenization Service** and **Web3 Service** to execute cryptographically signed transactions. |
| 19 | + |
| 20 | +1. **Mandate Validation**: Before any settlement occurs, the system validates the transaction against a signed **AP2 Mandate**. |
| 21 | +2. **Secure Signing**: The private keys never leave the Secure Enclave (Vault). The settlement transaction is signed within the vault. |
| 22 | +3. **On-Chain Execution**: The signed transaction is broadcast to the network (e.g., Ethereum, Polygon) for finality. |
| 23 | + |
| 24 | +## Using the CLI |
| 25 | + |
| 26 | +You can simulate or execute an x402 settlement using the `ocp` CLI: |
| 27 | + |
| 28 | +```bash |
| 29 | +ocp x402:settle 25.50 --token USDC --to 0x742d35Cc6634C0532925a3b844Bc454e4438f44e --mandate ./src/mandates/mandate_123.jwt |
| 30 | +``` |
| 31 | + |
| 32 | +## Developer Integration |
| 33 | + |
| 34 | +```javascript |
| 35 | +const { Web3Service } = require('@open-commerce-protocol/core'); |
| 36 | + |
| 37 | +const web3 = new Web3Service(tokenizationService); |
| 38 | + |
| 39 | +const settlement = await web3.executeX402Settlement({ |
| 40 | + keyTokenId: 'agent-key-token-id', |
| 41 | + to: '0xRecipientAddress', |
| 42 | + amount: 100.00, |
| 43 | + stablecoin: 'USDC', |
| 44 | + mandate: signedMandateJwt |
| 45 | +}); |
| 46 | + |
| 47 | +console.log(`Settlement ID: ${settlement.settlement_id}`); |
| 48 | +``` |
| 49 | + |
| 50 | +## Benefits |
| 51 | + |
| 52 | +* **24/7 Availability**: No more waiting for bank holidays or weekends. |
| 53 | +* **Low Latency**: Settlements occur as fast as the underlying blockchain confirms the transaction. |
| 54 | +* **Programmable**: Easily integrate settlement logic into autonomous agent workflows. |
| 55 | +* **Fiduciary Security**: Every settlement is backed by a verifiable chain of evidence (AP2 Mandate). |
0 commit comments