@cloudpayx/x402-pay 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +53 -0
- package/README.md +44 -14
- package/README.pre-pay-earn-release.bak +96 -0
- package/docs/API.md +76 -0
- package/docs/QUICKSTART.md +72 -0
- package/docs/agent-manifest.json +51 -0
- package/docs/agent-onboarding.md +236 -0
- package/examples/earn-http-server.mjs +60 -0
- package/examples/quickstart-validation.mjs +65 -0
- package/package.json +13 -3
- package/scripts/durable-purchase-lifecycle.mjs +34 -2
- package/scripts/persistent-spending-budget.mjs +101 -1
- package/scripts/public-node.mjs +2 -0
- package/scripts/secure-node-purchase.mjs +3 -1
- package/scripts/seller-earn.mjs +67 -0
- package/scripts/seller-http.mjs +287 -0
- package/scripts/seller-ledger-verifier.mjs +228 -0
- package/scripts/seller-node.mjs +180 -0
- package/scripts/seller-proof-guard.mjs +43 -0
- package/scripts/seller-transaction-guard.mjs +39 -0
- package/types/public-node.d.ts +20 -1
- package/README.before-0.2.3.bak +0 -94
package/AGENTS.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Autonomous Agent Integration — cloudpayX
|
|
2
|
+
|
|
3
|
+
**One SDK. Two capabilities. Three XRPL assets.**
|
|
4
|
+
|
|
5
|
+
Package: `@cloudpayx/x402-pay`
|
|
6
|
+
Install: `npm install @cloudpayx/x402-pay`
|
|
7
|
+
Network: XRPL mainnet (`xrpl:0`)
|
|
8
|
+
Protocol: x402 V2 exact
|
|
9
|
+
Assets: XRP, RLUSD, Circle USDC
|
|
10
|
+
|
|
11
|
+
No mandatory cloudpayX account, dashboard, subscription, or wallet brand.
|
|
12
|
+
|
|
13
|
+
## Discover
|
|
14
|
+
|
|
15
|
+
Read `README.md`, `docs/QUICKSTART.md`, `docs/API.md`,
|
|
16
|
+
and `types/public-node.d.ts`.
|
|
17
|
+
|
|
18
|
+
Use package-root exports only:
|
|
19
|
+
- validateSecureNodePurchase
|
|
20
|
+
- executeSecureNodePurchase
|
|
21
|
+
- reconcileSecureNodePurchase
|
|
22
|
+
- createCpXAgentEarn
|
|
23
|
+
|
|
24
|
+
## BUY workflow
|
|
25
|
+
|
|
26
|
+
1. Identify the seller, resource, exact price, asset, and invoice.
|
|
27
|
+
2. Obtain a compatible signer and explicit spending authorization.
|
|
28
|
+
3. Set per-asset budgets, fee ceiling, and one-shot constraints.
|
|
29
|
+
4. Use a durable private journal and unique intent ID.
|
|
30
|
+
5. Validate configuration before executing the authorized purchase.
|
|
31
|
+
6. Reconcile the original intent before claiming XRPL settlement.
|
|
32
|
+
7. Never retry an uncertain signed payment automatically.
|
|
33
|
+
|
|
34
|
+
Public Pay execution requires HTTP POST.
|
|
35
|
+
|
|
36
|
+
## SELL workflow
|
|
37
|
+
|
|
38
|
+
1. Choose a receiving wallet and supported XRPL asset.
|
|
39
|
+
2. Set amount, invoice ID, destination tag, and HTTPS facilitator.
|
|
40
|
+
3. Configure persistent replay and transaction journal storage.
|
|
41
|
+
4. Create the endpoint using createCpXAgentEarn.
|
|
42
|
+
5. Call initialize(), then forward requests to handle().
|
|
43
|
+
6. Deliver paid resources only through onPaid.
|
|
44
|
+
|
|
45
|
+
## Safety
|
|
46
|
+
|
|
47
|
+
Never publish seeds, private keys, or signing credentials.
|
|
48
|
+
Never treat HTTP success alone as validated XRPL settlement.
|
|
49
|
+
Never bypass authorization, spending caps, or replay protection.
|
|
50
|
+
Never substitute Base/EVM assets for XRPL assets.
|
|
51
|
+
Never change SDK payment internals just to simplify integration.
|
|
52
|
+
|
|
53
|
+
The SDK is free to install; XRPL fees and paid services are not free.
|
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
# cpX x402 Pay
|
|
1
|
+
# cpX x402 Pay + Earn
|
|
2
2
|
|
|
3
|
-
**XRPL-native
|
|
3
|
+
**XRPL-native payment infrastructure for autonomous AI agents.**
|
|
4
|
+
|
|
5
|
+
**One SDK. Two capabilities. Three XRPL assets.**
|
|
6
|
+
|
|
7
|
+
`npm install @cloudpayx/x402-pay`
|
|
4
8
|
|
|
5
9
|
cpX x402 Pay enables autonomous AI agents to purchase x402-protected services using XRP, RLUSD, and Circle USDC on the XRP Ledger.
|
|
6
10
|
|
|
@@ -8,14 +12,49 @@ The SDK provides wallet-agnostic signing integration, explicit payment authoriza
|
|
|
8
12
|
|
|
9
13
|
Self-funded agents can integrate without a cloudpayX account, dashboard, or mandatory wallet provider.
|
|
10
14
|
|
|
15
|
+
## Developer and agent integration guides
|
|
16
|
+
|
|
17
|
+
- [Quick Start](docs/QUICKSTART.md)
|
|
18
|
+
- [API Reference](docs/API.md)
|
|
19
|
+
- [Agent Instructions](AGENTS.md)
|
|
20
|
+
- [Machine-readable Manifest](docs/agent-manifest.json)
|
|
21
|
+
- [Earn HTTP Example](examples/earn-http-server.mjs)
|
|
22
|
+
|
|
11
23
|
## Installation
|
|
12
24
|
|
|
13
25
|
`npm install @cloudpayx/x402-pay`
|
|
14
26
|
|
|
15
|
-
**Network:** XRPL mainnet (`xrpl:0`)
|
|
16
|
-
**Protocol:** x402 V2, `exact`
|
|
27
|
+
**Network:** XRPL mainnet (`xrpl:0`)
|
|
28
|
+
**Protocol:** x402 V2, `exact`
|
|
17
29
|
**Assets:** XRP, RLUSD, Circle USDC
|
|
18
30
|
|
|
31
|
+
## Quick start: validate a payment configuration
|
|
32
|
+
|
|
33
|
+
Start with a no-wallet example before connecting a live XRPL signer.
|
|
34
|
+
|
|
35
|
+
From the SDK project:
|
|
36
|
+
|
|
37
|
+
npm install
|
|
38
|
+
node examples/quickstart-validation.mjs
|
|
39
|
+
|
|
40
|
+
The example imports the published SDK interface, configures an XRP purchase, and calls `validateSecureNodePurchase()`.
|
|
41
|
+
|
|
42
|
+
It uses placeholder addresses and a signer that refuses to sign. **No funds move.**
|
|
43
|
+
|
|
44
|
+
Validation confirms the guarded configuration structure. It does not authorize a payment, validate an address checksum, or verify settlement.
|
|
45
|
+
|
|
46
|
+
For live integration, replace the placeholders with a compatible XRPL signer, real payment details, and your own authorization policy. Use `executeSecureNodePurchase()` for execution and `reconcileSecureNodePurchase()` for settlement verification.
|
|
47
|
+
|
|
48
|
+
## cpX x402 Earn — Agent monetization
|
|
49
|
+
|
|
50
|
+
Turn agent capabilities into paid services with XRPL-native settlement.
|
|
51
|
+
|
|
52
|
+
cpX x402 Earn verifies payment requirements, enforces persistent replay protection, checks transaction identity, and independently confirms XRPL ledger settlement before delivering protected resources.
|
|
53
|
+
|
|
54
|
+
**Security by design:** Unsupported payment-processing sequences are rejected rather than permitted to bypass settlement verification.
|
|
55
|
+
|
|
56
|
+
The public SDK exposes `createCpXAgentEarn()` for configuring a protected XRPL payment endpoint.
|
|
57
|
+
|
|
19
58
|
## Capabilities
|
|
20
59
|
|
|
21
60
|
- **Autonomous agent payments:** Agents can purchase compatible x402 resources using their own XRPL signing infrastructure.
|
|
@@ -37,6 +76,7 @@ Import the guarded payment operations from `@cloudpayx/x402-pay`.
|
|
|
37
76
|
| `validateSecureNodePurchase` | Validate a proposed guarded payment configuration. |
|
|
38
77
|
| `executeSecureNodePurchase` | Execute a policy-controlled XRPL x402 purchase. |
|
|
39
78
|
| `reconcileSecureNodePurchase` | Reconcile an existing purchase against validated XRPL ledger evidence. |
|
|
79
|
+
| `createCpXAgentEarn` | Protect and monetize agent services with verified XRPL settlement. |
|
|
40
80
|
|
|
41
81
|
Payment execution requires compatible signing infrastructure and application-supplied authorization and policy configuration.
|
|
42
82
|
|
|
@@ -69,16 +109,6 @@ Applications must secure their XRPL signing credentials independently. An agent
|
|
|
69
109
|
|
|
70
110
|
Issued-token payments require applicable trustlines, sufficient balances, and XRP for network fees and reserves. Third-party resource delivery depends on the seller and network conditions.
|
|
71
111
|
|
|
72
|
-
## Testing
|
|
73
|
-
|
|
74
|
-
The v0.2.2 implementation completed:
|
|
75
|
-
|
|
76
|
-
- **234 automated tests passed**
|
|
77
|
-
- **0 test failures**
|
|
78
|
-
- **Successful TypeScript build**
|
|
79
|
-
|
|
80
|
-
Test coverage includes supported assets, authorization, guarded signing, persistent budgets, transaction journaling, HTTP resource protections, and settlement reconciliation.
|
|
81
|
-
|
|
82
112
|
## Resources
|
|
83
113
|
|
|
84
114
|
- Website: https://cloudpayx.com
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# cpX x402 Pay
|
|
2
|
+
|
|
3
|
+
**XRPL-native x402 payments for autonomous AI agents.**
|
|
4
|
+
|
|
5
|
+
cpX x402 Pay enables autonomous AI agents to purchase x402-protected services using XRP, RLUSD, and Circle USDC on the XRP Ledger.
|
|
6
|
+
|
|
7
|
+
The SDK provides wallet-agnostic signing integration, explicit payment authorization, spending controls, guarded transactions, persistent payment tracking, and validated-ledger settlement reconciliation.
|
|
8
|
+
|
|
9
|
+
Self-funded agents can integrate without a cloudpayX account, dashboard, or mandatory wallet provider.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
`npm install @cloudpayx/x402-pay`
|
|
14
|
+
|
|
15
|
+
**Network:** XRPL mainnet (`xrpl:0`)
|
|
16
|
+
**Protocol:** x402 V2, `exact`
|
|
17
|
+
**Assets:** XRP, RLUSD, Circle USDC
|
|
18
|
+
|
|
19
|
+
## Quick start: validate a payment configuration
|
|
20
|
+
|
|
21
|
+
Start with a no-wallet example before connecting a live XRPL signer.
|
|
22
|
+
|
|
23
|
+
From the SDK project:
|
|
24
|
+
|
|
25
|
+
npm install
|
|
26
|
+
node examples/quickstart-validation.mjs
|
|
27
|
+
|
|
28
|
+
The example imports the published SDK interface, configures an XRP purchase, and calls `validateSecureNodePurchase()`.
|
|
29
|
+
|
|
30
|
+
It uses placeholder addresses and a signer that refuses to sign. **No funds move.**
|
|
31
|
+
|
|
32
|
+
Validation confirms the guarded configuration structure. It does not authorize a payment, validate an address checksum, or verify settlement.
|
|
33
|
+
|
|
34
|
+
For live integration, replace the placeholders with a compatible XRPL signer, real payment details, and your own authorization policy. Use `executeSecureNodePurchase()` for execution and `reconcileSecureNodePurchase()` for settlement verification.
|
|
35
|
+
|
|
36
|
+
## Capabilities
|
|
37
|
+
|
|
38
|
+
- **Autonomous agent payments:** Agents can purchase compatible x402 resources using their own XRPL signing infrastructure.
|
|
39
|
+
- **Wallet-agnostic integration:** No mandatory wallet brand or cloudpayX custody.
|
|
40
|
+
- **Three-asset support:** Native XRP, Ripple-issued RLUSD, and Circle-issued USDC with issuer validation.
|
|
41
|
+
- **Payment authorization:** Explicit autonomous opt-in or application-controlled approval.
|
|
42
|
+
- **Spending controls:** Per-asset limits, persistent aggregate budgets, recipient restrictions, and transaction fee ceilings.
|
|
43
|
+
- **Guarded signing:** Checks transaction destination, asset, amount, invoice binding, fees, and other transaction constraints.
|
|
44
|
+
- **Durable payment records:** Persistent journals and duplicate-payment protections.
|
|
45
|
+
- **Settlement verification:** Reconciliation against validated XRPL transaction evidence.
|
|
46
|
+
- **Protected resource access:** HTTPS validation, anti-SSRF protections, and redirect restrictions.
|
|
47
|
+
|
|
48
|
+
## Public SDK API
|
|
49
|
+
|
|
50
|
+
Import the guarded payment operations from `@cloudpayx/x402-pay`.
|
|
51
|
+
|
|
52
|
+
| Export | Purpose |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `validateSecureNodePurchase` | Validate a proposed guarded payment configuration. |
|
|
55
|
+
| `executeSecureNodePurchase` | Execute a policy-controlled XRPL x402 purchase. |
|
|
56
|
+
| `reconcileSecureNodePurchase` | Reconcile an existing purchase against validated XRPL ledger evidence. |
|
|
57
|
+
|
|
58
|
+
Payment execution requires compatible signing infrastructure and application-supplied authorization and policy configuration.
|
|
59
|
+
|
|
60
|
+
## Supported assets
|
|
61
|
+
|
|
62
|
+
| Asset | Network | Amount format |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| XRP | XRPL mainnet | Integer drops |
|
|
65
|
+
| RLUSD | XRPL mainnet | Decimal token amounts, Ripple issuer-bound |
|
|
66
|
+
| Circle USDC | XRPL mainnet | Decimal token amounts, Circle issuer-bound |
|
|
67
|
+
|
|
68
|
+
**cpX x402 Pay is XRPL-only.** It does not execute Base/EVM payments, automatically swap tokens, or substitute unrelated assets with similar names.
|
|
69
|
+
|
|
70
|
+
## Payment lifecycle
|
|
71
|
+
|
|
72
|
+
1. An agent requests an x402-protected resource.
|
|
73
|
+
2. The resource returns payment requirements.
|
|
74
|
+
3. The SDK validates the payment requirements and configured spending authorization.
|
|
75
|
+
4. The guarded transaction is signed and submitted through the payment flow.
|
|
76
|
+
5. Purchase state and transaction evidence are preserved.
|
|
77
|
+
6. Ledger reconciliation verifies the settlement outcome.
|
|
78
|
+
|
|
79
|
+
Uncertain payment results require reconciliation rather than automatic duplicate payment attempts.
|
|
80
|
+
|
|
81
|
+
## Security architecture
|
|
82
|
+
|
|
83
|
+
The guarded SDK interface incorporates explicit authorization, spending budgets, transaction-signing restrictions, invoice binding, issuer validation, fee controls, duplicate-payment protection, safe resource-host validation, and ledger reconciliation.
|
|
84
|
+
|
|
85
|
+
Applications must secure their XRPL signing credentials independently. An agent with unrestricted access to wallet keys can bypass local SDK policies outside the guarded interface.
|
|
86
|
+
|
|
87
|
+
Issued-token payments require applicable trustlines, sufficient balances, and XRP for network fees and reserves. Third-party resource delivery depends on the seller and network conditions.
|
|
88
|
+
|
|
89
|
+
## Resources
|
|
90
|
+
|
|
91
|
+
- Website: https://cloudpayx.com
|
|
92
|
+
- Agent infrastructure: https://api.cloudpayxagent.xyz
|
|
93
|
+
- npm: https://www.npmjs.com/package/@cloudpayx/x402-pay
|
|
94
|
+
- XRPL x402 specification: https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_xrpl.md
|
|
95
|
+
|
|
96
|
+
**cloudpayX | Infrastructure for the autonomous economy**
|
package/docs/API.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# cpX x402 Pay + Earn — Public API
|
|
2
|
+
|
|
3
|
+
Package: `@cloudpayx/x402-pay`
|
|
4
|
+
Network: XRPL mainnet only (`xrpl:0`).
|
|
5
|
+
|
|
6
|
+
## Pay
|
|
7
|
+
|
|
8
|
+
`validateSecureNodePurchase(options)` returns true or throws.
|
|
9
|
+
It validates configuration shape, not settlement or authorization.
|
|
10
|
+
|
|
11
|
+
`executeSecureNodePurchase(options)` starts at most one guarded purchase.
|
|
12
|
+
Its response includes:
|
|
13
|
+
- status: `HTTP_RESPONSE_LEDGER_UNVERIFIED`
|
|
14
|
+
- httpStatus
|
|
15
|
+
- paymentResponseHeaderPresent
|
|
16
|
+
- journalStatus
|
|
17
|
+
|
|
18
|
+
Required options:
|
|
19
|
+
- intent: intentId, payer, seller, resource, asset, amount
|
|
20
|
+
- journalDir: private durable directory
|
|
21
|
+
- budgetCaps: xrpDrops, rlusd, usdc (positive strings)
|
|
22
|
+
- signer: matching classicAddress and sign function
|
|
23
|
+
- policy: explicit payment authorization configuration
|
|
24
|
+
- oneShot: recipient, asset, exactAmount, maxFeeDrops
|
|
25
|
+
- maxFeeDrops: positive string matching oneShot
|
|
26
|
+
- request: matching URL, POST method, string body
|
|
27
|
+
|
|
28
|
+
For issued tokens, oneShot additionally requires issuer and maxSendMax.
|
|
29
|
+
Optional timeoutMs: 1–60000, default 20000.
|
|
30
|
+
|
|
31
|
+
Initial requests cannot contain payment-signature, x-payment,
|
|
32
|
+
authorization, or cookie headers.
|
|
33
|
+
|
|
34
|
+
`reconcileSecureNodePurchase({ journalDir, intentId })` performs read-only
|
|
35
|
+
ledger recovery. Successful results contain:
|
|
36
|
+
- status: VALIDATED_SUCCESS
|
|
37
|
+
- transactionHash
|
|
38
|
+
- ledgerIndex
|
|
39
|
+
- deliveredAmount
|
|
40
|
+
- asset
|
|
41
|
+
- feeDrops
|
|
42
|
+
- invoiceID
|
|
43
|
+
|
|
44
|
+
Reconciliation never resubmits a transaction.
|
|
45
|
+
|
|
46
|
+
## Earn
|
|
47
|
+
|
|
48
|
+
`createCpXAgentEarn(options)` accepts:
|
|
49
|
+
- walletAddress: valid XRPL classic receiving address
|
|
50
|
+
- asset: XRP, RLUSD, or USDC
|
|
51
|
+
- amount: positive string (XRP in drops)
|
|
52
|
+
- invoiceId: 1–256 characters
|
|
53
|
+
- destinationTag: integer 0–4294967295
|
|
54
|
+
- facilitatorUrl: HTTPS URL
|
|
55
|
+
- journalDir: persistent private directory
|
|
56
|
+
- onPaid: (request, settlement) => Response or Promise<Response>
|
|
57
|
+
- method: GET or POST, optional; default POST
|
|
58
|
+
- path: valid route, optional; default /paid
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
- initialize(): initialize x402 resource server
|
|
62
|
+
- handle(request): process Fetch API Request and return Response
|
|
63
|
+
|
|
64
|
+
Earn uses proof replay protection, transaction identity checks, and
|
|
65
|
+
validated-ledger verification before paid resource delivery.
|
|
66
|
+
Unsupported processing sequences fail closed.
|
|
67
|
+
|
|
68
|
+
## Asset identifiers
|
|
69
|
+
|
|
70
|
+
RLUSD issuer: rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De
|
|
71
|
+
USDC issuer: rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE
|
|
72
|
+
|
|
73
|
+
This SDK does not support Base/EVM settlement.
|
|
74
|
+
Do not expose wallet secrets or bypass public guarded APIs.
|
|
75
|
+
|
|
76
|
+
Canonical TypeScript signatures: `types/public-node.d.ts`.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# cpX x402 Pay + Earn — Quick Start
|
|
2
|
+
|
|
3
|
+
**One SDK. Two capabilities. Three XRPL assets.**
|
|
4
|
+
|
|
5
|
+
Install: `npm install @cloudpayx/x402-pay`
|
|
6
|
+
|
|
7
|
+
Network: XRPL mainnet (`xrpl:0`).
|
|
8
|
+
Protocol: x402 V2, exact.
|
|
9
|
+
Assets: XRP, Ripple RLUSD, Circle USDC.
|
|
10
|
+
|
|
11
|
+
No mandatory cloudpayX account, subscription, dashboard, or wallet provider.
|
|
12
|
+
XRPL fees, purchased services, and third-party facilitator charges may apply.
|
|
13
|
+
|
|
14
|
+
## Pay — Buy agent services
|
|
15
|
+
|
|
16
|
+
Import `validateSecureNodePurchase`, `executeSecureNodePurchase`, and
|
|
17
|
+
`reconcileSecureNodePurchase` from `@cloudpayx/x402-pay`.
|
|
18
|
+
|
|
19
|
+
Start with `node examples/quickstart-validation.mjs` in the source repository.
|
|
20
|
+
This validates configuration without moving funds.
|
|
21
|
+
|
|
22
|
+
For an authorized live purchase, provide:
|
|
23
|
+
- Stable unique intent ID (at least 12 characters)
|
|
24
|
+
- Payer, seller, public HTTPS resource, asset, and exact amount
|
|
25
|
+
- Compatible XRPL signer with matching classicAddress
|
|
26
|
+
- Explicit authorization policy and recipient restrictions
|
|
27
|
+
- Positive persistent budgets for XRP drops, RLUSD, and USDC
|
|
28
|
+
- One-shot guard matching recipient, asset, amount, and fee ceiling
|
|
29
|
+
- Issuer and maxSendMax for RLUSD or USDC
|
|
30
|
+
- Private durable journal directory
|
|
31
|
+
- POST request with a string body
|
|
32
|
+
|
|
33
|
+
Call `validateSecureNodePurchase(options)` to check configuration.
|
|
34
|
+
Call `executeSecureNodePurchase(options)` only after authorization.
|
|
35
|
+
|
|
36
|
+
An HTTP response is NOT verified XRPL settlement.
|
|
37
|
+
|
|
38
|
+
For an existing journaled purchase:
|
|
39
|
+
|
|
40
|
+
import { reconcileSecureNodePurchase } from "@cloudpayx/x402-pay";
|
|
41
|
+
|
|
42
|
+
const receipt = await reconcileSecureNodePurchase({
|
|
43
|
+
journalDir: "./private-payment-journal",
|
|
44
|
+
intentId: "original-unique-intent-id"
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
Only a `VALIDATED_SUCCESS` receipt establishes settlement through this API.
|
|
48
|
+
Never automatically repeat a payment after a timeout or uncertain outcome.
|
|
49
|
+
|
|
50
|
+
## Earn — Sell agent services
|
|
51
|
+
|
|
52
|
+
Import `createCpXAgentEarn` from `@cloudpayx/x402-pay`.
|
|
53
|
+
|
|
54
|
+
Configure a receiving wallet, asset, positive amount, invoice ID,
|
|
55
|
+
destination tag, HTTPS facilitator, durable journal, and `onPaid` callback.
|
|
56
|
+
|
|
57
|
+
Call `initialize()` before routing incoming Fetch API Request objects
|
|
58
|
+
through `handle(request)`. Return the resulting Response to the caller.
|
|
59
|
+
|
|
60
|
+
See `examples/earn-http-server.mjs` for a Node HTTP adapter.
|
|
61
|
+
The paid service must only be delivered from `onPaid`.
|
|
62
|
+
|
|
63
|
+
## Amounts
|
|
64
|
+
|
|
65
|
+
- XRP: positive integer drops (1 XRP = 1,000,000 drops).
|
|
66
|
+
- RLUSD: positive decimal units, Ripple issuer.
|
|
67
|
+
- USDC: positive decimal units, Circle issuer.
|
|
68
|
+
|
|
69
|
+
Issued-token wallets need the applicable trustlines, balances, and XRP
|
|
70
|
+
for fees and reserves.
|
|
71
|
+
|
|
72
|
+
See `docs/API.md` and `AGENTS.md`.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cpX x402 Pay + Earn",
|
|
3
|
+
"provider": "cloudpayX",
|
|
4
|
+
"package": "@cloudpayx/x402-pay",
|
|
5
|
+
"network": "xrpl:0",
|
|
6
|
+
"protocol": {
|
|
7
|
+
"name": "x402",
|
|
8
|
+
"version": 2,
|
|
9
|
+
"scheme": "exact"
|
|
10
|
+
},
|
|
11
|
+
"assets": [
|
|
12
|
+
{
|
|
13
|
+
"symbol": "XRP",
|
|
14
|
+
"unit": "drops"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"symbol": "RLUSD",
|
|
18
|
+
"issuer": "rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"symbol": "USDC",
|
|
22
|
+
"issuer": "rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"pay": {
|
|
26
|
+
"exports": [
|
|
27
|
+
"validateSecureNodePurchase",
|
|
28
|
+
"executeSecureNodePurchase",
|
|
29
|
+
"reconcileSecureNodePurchase"
|
|
30
|
+
],
|
|
31
|
+
"httpMethod": "POST",
|
|
32
|
+
"requiresSigner": true,
|
|
33
|
+
"requiresAuthorization": true
|
|
34
|
+
},
|
|
35
|
+
"earn": {
|
|
36
|
+
"export": "createCpXAgentEarn",
|
|
37
|
+
"httpMethods": [
|
|
38
|
+
"GET",
|
|
39
|
+
"POST"
|
|
40
|
+
],
|
|
41
|
+
"requiresHttpsFacilitator": true,
|
|
42
|
+
"requiresValidatedSettlement": true
|
|
43
|
+
},
|
|
44
|
+
"documentation": [
|
|
45
|
+
"README.md",
|
|
46
|
+
"docs/QUICKSTART.md",
|
|
47
|
+
"docs/API.md",
|
|
48
|
+
"AGENTS.md"
|
|
49
|
+
],
|
|
50
|
+
"cloudpayxAccountRequired": false
|
|
51
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# cpX x402 Pay | Autonomous Agent Onboarding
|
|
2
|
+
|
|
3
|
+
Network: XRPL mainnet (xrpl:0)
|
|
4
|
+
Protocol: x402 V2, exact
|
|
5
|
+
SDK: @cloudpayx/x402-pay
|
|
6
|
+
Status: Integration guidance
|
|
7
|
+
Custody: None
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
This guide helps autonomous agents prepare their own XRPL wallets
|
|
12
|
+
to purchase x402-protected resources through cpX x402 Pay.
|
|
13
|
+
|
|
14
|
+
cloudpayX does not create wallets, hold private keys, fund accounts,
|
|
15
|
+
or independently authorize an agent's spending.
|
|
16
|
+
|
|
17
|
+
An agent may use its own wallet infrastructure or an existing
|
|
18
|
+
compatible XRPL wallet signer.
|
|
19
|
+
|
|
20
|
+
## 1. Prepare an XRPL wallet
|
|
21
|
+
|
|
22
|
+
If you already control an XRPL wallet, continue to Step 2.
|
|
23
|
+
|
|
24
|
+
Otherwise:
|
|
25
|
+
|
|
26
|
+
1. Choose an existing XRPL-compatible wallet or wallet library.
|
|
27
|
+
2. Generate credentials using that wallet's own secure process.
|
|
28
|
+
3. Keep private keys and recovery credentials under your control.
|
|
29
|
+
4. Obtain the wallet's XRPL classic address.
|
|
30
|
+
5. Ensure your signing infrastructure can sign XRPL transactions.
|
|
31
|
+
|
|
32
|
+
Never send wallet seeds or private keys to cloudpayX.
|
|
33
|
+
|
|
34
|
+
XRPL account documentation:
|
|
35
|
+
https://xrpl.org/docs/concepts/accounts
|
|
36
|
+
|
|
37
|
+
## 2. Activate and fund the account
|
|
38
|
+
|
|
39
|
+
An XRPL wallet address must be funded before its account exists
|
|
40
|
+
on the ledger.
|
|
41
|
+
|
|
42
|
+
Obtain sufficient XRP for:
|
|
43
|
+
|
|
44
|
+
- Account activation and current reserve requirements
|
|
45
|
+
- Additional ledger objects, where applicable
|
|
46
|
+
- XRPL transaction fees
|
|
47
|
+
- XRP payments, if purchasing with XRP
|
|
48
|
+
|
|
49
|
+
Check current reserve requirements before funding.
|
|
50
|
+
|
|
51
|
+
Reserve documentation:
|
|
52
|
+
https://xrpl.org/docs/concepts/accounts/reserves
|
|
53
|
+
|
|
54
|
+
cpX x402 Pay does not supply XRP automatically.
|
|
55
|
+
|
|
56
|
+
## 3. Supported payment assets
|
|
57
|
+
|
|
58
|
+
cpX x402 Pay supports only these mainnet assets:
|
|
59
|
+
|
|
60
|
+
XRP:
|
|
61
|
+
Network: xrpl:0
|
|
62
|
+
Currency: XRP
|
|
63
|
+
Issuer: none
|
|
64
|
+
Payment amount: integer drops
|
|
65
|
+
|
|
66
|
+
RLUSD:
|
|
67
|
+
Network: xrpl:0
|
|
68
|
+
Currency: 524C555344000000000000000000000000000000
|
|
69
|
+
Issuer: rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De
|
|
70
|
+
Payment amount: decimal token units
|
|
71
|
+
|
|
72
|
+
Circle USDC:
|
|
73
|
+
Network: xrpl:0
|
|
74
|
+
Currency: 5553444300000000000000000000000000000000
|
|
75
|
+
Issuer: rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE
|
|
76
|
+
Payment amount: decimal token units
|
|
77
|
+
|
|
78
|
+
These identifiers reflect the existing cpX payment implementation.
|
|
79
|
+
|
|
80
|
+
Do not substitute another issuer merely because a token uses
|
|
81
|
+
the same symbol.
|
|
82
|
+
|
|
83
|
+
For XRP, 1000000 drops equals 1 XRP.
|
|
84
|
+
|
|
85
|
+
The SDK's payment intent, signing guard, and budget policies
|
|
86
|
+
must use their documented amount formats consistently.
|
|
87
|
+
|
|
88
|
+
## 4. Prepare RLUSD or USDC
|
|
89
|
+
|
|
90
|
+
If paying with XRP, no token trust line is required.
|
|
91
|
+
|
|
92
|
+
If paying with RLUSD or USDC:
|
|
93
|
+
|
|
94
|
+
1. Verify the selected issuer and currency identity.
|
|
95
|
+
2. Use your existing wallet's TrustSet capability to establish
|
|
96
|
+
any required trust line.
|
|
97
|
+
3. Ensure the account has enough XRP for applicable reserves
|
|
98
|
+
and transaction fees.
|
|
99
|
+
4. Acquire the intended token through a suitable provider.
|
|
100
|
+
5. Check the token balance and any applicable restrictions.
|
|
101
|
+
|
|
102
|
+
A trust line alone does not guarantee the ability to spend a token.
|
|
103
|
+
|
|
104
|
+
Issuer authorization, freezes, and other ledger restrictions
|
|
105
|
+
may prevent a transaction.
|
|
106
|
+
|
|
107
|
+
Trust line documentation:
|
|
108
|
+
https://xrpl.org/docs/concepts/tokens/fungible-tokens/trust-line-tokens
|
|
109
|
+
|
|
110
|
+
## 5. Install cpX x402 Pay
|
|
111
|
+
|
|
112
|
+
npm install @cloudpayx/x402-pay
|
|
113
|
+
|
|
114
|
+
The SDK is wallet-agnostic.
|
|
115
|
+
|
|
116
|
+
It does not require:
|
|
117
|
+
- A cloudpayX account
|
|
118
|
+
- A cloudpayX dashboard
|
|
119
|
+
- A particular wallet brand
|
|
120
|
+
- Hosted signing or custody
|
|
121
|
+
|
|
122
|
+
## 6. Configure an existing signer
|
|
123
|
+
|
|
124
|
+
The public secure purchase function accepts a compatible
|
|
125
|
+
XRPL signer through its signer option.
|
|
126
|
+
|
|
127
|
+
That signer must correspond to the payment intent's payer
|
|
128
|
+
account and support the signing interface required by the SDK.
|
|
129
|
+
|
|
130
|
+
For example, the SDK's validation example represents a signer
|
|
131
|
+
using classicAddress and sign.
|
|
132
|
+
|
|
133
|
+
This guide does not generate a signer or store its credentials.
|
|
134
|
+
|
|
135
|
+
An autonomous agent must establish its own spending authority,
|
|
136
|
+
permitted recipients, per-asset limits, and transaction fee caps.
|
|
137
|
+
|
|
138
|
+
## 7. Validate before paying
|
|
139
|
+
|
|
140
|
+
The working public SDK exposes:
|
|
141
|
+
|
|
142
|
+
- validateSecureNodePurchase(options)
|
|
143
|
+
- executeSecureNodePurchase(options)
|
|
144
|
+
- reconcileSecureNodePurchase(options)
|
|
145
|
+
|
|
146
|
+
Start with:
|
|
147
|
+
|
|
148
|
+
node examples/quickstart-validation.mjs
|
|
149
|
+
|
|
150
|
+
Run that command from the SDK source repository.
|
|
151
|
+
|
|
152
|
+
This example checks payment configuration structure using
|
|
153
|
+
placeholder addresses and a signer that refuses to sign.
|
|
154
|
+
|
|
155
|
+
It does NOT perform a payment.
|
|
156
|
+
|
|
157
|
+
It does NOT confirm that a wallet is funded or payment-ready.
|
|
158
|
+
|
|
159
|
+
For a real purchase, use valid account and seller details,
|
|
160
|
+
a compatible agent-controlled signer, configured policies,
|
|
161
|
+
a durable journal location, and the original resource request.
|
|
162
|
+
|
|
163
|
+
## 8. Execute a supported x402 purchase
|
|
164
|
+
|
|
165
|
+
Follow the existing SDK's guarded payment workflow.
|
|
166
|
+
|
|
167
|
+
The agent requests an x402-protected resource and receives
|
|
168
|
+
the seller's payment requirements.
|
|
169
|
+
|
|
170
|
+
The SDK validates the transaction requirements, economic
|
|
171
|
+
intent, signer, spending authorization, and configured limits.
|
|
172
|
+
|
|
173
|
+
The payment flow must preserve its original transaction
|
|
174
|
+
details and enforce the signing restrictions.
|
|
175
|
+
|
|
176
|
+
Call executeSecureNodePurchase() only with a valid,
|
|
177
|
+
independently authorized secure purchase configuration.
|
|
178
|
+
|
|
179
|
+
Do not manually manufacture payment-signature headers.
|
|
180
|
+
|
|
181
|
+
The existing x402 client handles the signed payment proof
|
|
182
|
+
inside the guarded payment flow.
|
|
183
|
+
|
|
184
|
+
## 9. Verify settlement
|
|
185
|
+
|
|
186
|
+
An HTTP success response is not proof of XRPL settlement.
|
|
187
|
+
|
|
188
|
+
Use reconcileSecureNodePurchase() with the original
|
|
189
|
+
journalDir and intentId to verify existing transaction
|
|
190
|
+
evidence against the validated XRP Ledger.
|
|
191
|
+
|
|
192
|
+
For an uncertain or interrupted payment result:
|
|
193
|
+
|
|
194
|
+
- Preserve the original intent and durable journal.
|
|
195
|
+
- Reconcile the previous transaction.
|
|
196
|
+
- Do not blindly submit a replacement payment.
|
|
197
|
+
|
|
198
|
+
A new payment attempt is not automatically authorized by
|
|
199
|
+
a timeout or an unavailable ledger response.
|
|
200
|
+
|
|
201
|
+
## 10. Technical references
|
|
202
|
+
|
|
203
|
+
SDK package:
|
|
204
|
+
https://www.npmjs.com/package/@cloudpayx/x402-pay
|
|
205
|
+
|
|
206
|
+
Source:
|
|
207
|
+
https://github.com/cpayX3/cpx-x402-pay
|
|
208
|
+
|
|
209
|
+
XRPL x402 specification:
|
|
210
|
+
https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_xrpl.md
|
|
211
|
+
|
|
212
|
+
XRPL account setup:
|
|
213
|
+
https://xrpl.org/docs/concepts/accounts
|
|
214
|
+
|
|
215
|
+
XRPL reserves:
|
|
216
|
+
https://xrpl.org/docs/concepts/accounts/reserves
|
|
217
|
+
|
|
218
|
+
XRPL trust lines:
|
|
219
|
+
https://xrpl.org/docs/concepts/tokens/fungible-tokens/trust-line-tokens
|
|
220
|
+
|
|
221
|
+
cloudpayX agent infrastructure:
|
|
222
|
+
https://api.cloudpayxagent.xyz
|
|
223
|
+
|
|
224
|
+
## Important limitations
|
|
225
|
+
|
|
226
|
+
This document is guidance, not a wallet-generation service.
|
|
227
|
+
|
|
228
|
+
It does not create accounts, distribute funding, sign
|
|
229
|
+
transactions, approve payments, or guarantee resource delivery.
|
|
230
|
+
|
|
231
|
+
The existing cpX x402 Pay SDK remains the authority for
|
|
232
|
+
supported payment behavior.
|
|
233
|
+
|
|
234
|
+
Before a real payment, verify the installed SDK version,
|
|
235
|
+
the seller's payment requirements, and all signing and
|
|
236
|
+
authorization policies.
|