x402-proxy 0.9.4 → 0.10.1
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/CHANGELOG.md +38 -1
- package/README.md +7 -3
- package/dist/bin/cli.js +1067 -156
- package/dist/openclaw/plugin.d.ts +12 -56
- package/dist/openclaw/plugin.js +958 -221
- package/dist/openclaw.plugin.json +69 -4
- package/dist/{setup-Dp5fS7ob.js → setup-DtKrojW1.js} +1 -1
- package/dist/setup-EX1_teNg.js +3 -0
- package/dist/{status-BZTToWE_.js → status-B5oH1nHv.js} +2 -2
- package/dist/status-DlR8yBrK.js +3 -0
- package/dist/wallet-7XKcknNZ.js +3 -0
- package/dist/{wallet-CqUc-ZFn.js → wallet-DqGROXlC.js} +18 -28
- package/openclaw.plugin.json +69 -4
- package/package.json +13 -4
- package/skills/SKILL.md +3 -1
- package/skills/references/openclaw-plugin.md +21 -11
- package/dist/setup-B6xRV8Ue.js +0 -3
- package/dist/status-Bj3U-W2M.js +0 -3
- package/dist/wallet-4C9EL4Iv.js +0 -3
- /package/dist/{derive-EDXzwKW2.js → derive-CY0En_Y3.js} +0 -0
|
@@ -1,18 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "x402-proxy",
|
|
3
|
-
"name": "x402 Proxy",
|
|
4
|
-
"description": "x402
|
|
3
|
+
"name": "mpp/x402 Payments Proxy",
|
|
4
|
+
"description": "x402 and MPP payments, wallet tools, and paid inference proxying",
|
|
5
5
|
"version": "1.0.0",
|
|
6
|
+
"providers": ["surf"],
|
|
7
|
+
"autoEnableWhenConfiguredProviders": ["surf"],
|
|
8
|
+
"skills": ["skills"],
|
|
9
|
+
"contracts": {
|
|
10
|
+
"tools": ["x_wallet", "x_balance", "x_request", "x_payment"]
|
|
11
|
+
},
|
|
6
12
|
"configSchema": {
|
|
7
13
|
"type": "object",
|
|
14
|
+
"additionalProperties": false,
|
|
8
15
|
"properties": {
|
|
9
16
|
"providers": {
|
|
10
17
|
"type": "object",
|
|
11
|
-
"description": "Provider catalog keyed by name
|
|
18
|
+
"description": "Provider catalog keyed by name. Defaults to the built-in surf provider when omitted.",
|
|
19
|
+
"additionalProperties": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"properties": {
|
|
23
|
+
"baseUrl": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Gateway base path for this provider, typically under /x402-proxy"
|
|
26
|
+
},
|
|
27
|
+
"upstreamUrl": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "Upstream inference origin to proxy to"
|
|
30
|
+
},
|
|
31
|
+
"protocol": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"enum": ["x402", "mpp", "auto"],
|
|
34
|
+
"description": "Payment protocol for this provider. Defaults to mpp."
|
|
35
|
+
},
|
|
36
|
+
"mppSessionBudget": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "Maximum USDC budget to lock for MPP sessions for this provider (default: 0.5)"
|
|
39
|
+
},
|
|
40
|
+
"models": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"description": "Static OpenClaw model catalog entries for this provider"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"protocol": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": ["x402", "mpp", "auto"],
|
|
50
|
+
"description": "Default payment protocol fallback for providers that do not override it."
|
|
51
|
+
},
|
|
52
|
+
"mppSessionBudget": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Default maximum USDC budget to lock for MPP sessions (default: 0.5)"
|
|
12
55
|
},
|
|
13
56
|
"keypairPath": {
|
|
14
57
|
"type": "string",
|
|
15
|
-
"description": "Optional path to Solana keypair JSON file (overrides x402-proxy wallet resolution)"
|
|
58
|
+
"description": "Optional path to Solana keypair JSON file (overrides x402-proxy wallet resolution for Solana/x402 surfaces)"
|
|
16
59
|
},
|
|
17
60
|
"rpcUrl": {
|
|
18
61
|
"type": "string",
|
|
@@ -24,5 +67,27 @@
|
|
|
24
67
|
}
|
|
25
68
|
},
|
|
26
69
|
"required": []
|
|
70
|
+
},
|
|
71
|
+
"uiHints": {
|
|
72
|
+
"protocol": {
|
|
73
|
+
"label": "Default protocol",
|
|
74
|
+
"help": "Used only when a provider entry does not set its own protocol."
|
|
75
|
+
},
|
|
76
|
+
"mppSessionBudget": {
|
|
77
|
+
"label": "Default MPP budget",
|
|
78
|
+
"placeholder": "0.5"
|
|
79
|
+
},
|
|
80
|
+
"keypairPath": {
|
|
81
|
+
"label": "Solana keypair path",
|
|
82
|
+
"advanced": true
|
|
83
|
+
},
|
|
84
|
+
"rpcUrl": {
|
|
85
|
+
"label": "Solana RPC URL",
|
|
86
|
+
"advanced": true
|
|
87
|
+
},
|
|
88
|
+
"dashboardUrl": {
|
|
89
|
+
"label": "Dashboard URL",
|
|
90
|
+
"advanced": true
|
|
91
|
+
}
|
|
27
92
|
}
|
|
28
93
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { d as saveWalletFile, i as getConfigDirShort, l as loadWalletFile, n as deriveSolanaKeypair, o as getWalletPath, r as generateMnemonic, s as isConfigured, t as deriveEvmKeypair, u as saveConfig } from "./derive-
|
|
2
|
+
import { d as saveWalletFile, i as getConfigDirShort, l as loadWalletFile, n as deriveSolanaKeypair, o as getWalletPath, r as generateMnemonic, s as isConfigured, t as deriveEvmKeypair, u as saveConfig } from "./derive-CY0En_Y3.js";
|
|
3
3
|
import { buildCommand } from "@stricli/core";
|
|
4
4
|
import pc from "picocolors";
|
|
5
5
|
import * as prompts from "@clack/prompts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { c as resolveWallet, f as formatAmount, g as dim, h as readHistory, m as formatUsdcValue, n as fetchAllBalances, p as formatTxLine, t as balanceLine, u as calcSpend } from "./wallet-DqGROXlC.js";
|
|
3
|
+
import { a as getHistoryPath, c as loadConfig, i as getConfigDirShort } from "./derive-CY0En_Y3.js";
|
|
4
4
|
import { buildCommand } from "@stricli/core";
|
|
5
5
|
import pc from "picocolors";
|
|
6
6
|
//#region src/commands/status.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as getHistoryPath, l as loadWalletFile, n as deriveSolanaKeypair, t as deriveEvmKeypair } from "./derive-
|
|
2
|
+
import { a as getHistoryPath, l as loadWalletFile, n as deriveSolanaKeypair, t as deriveEvmKeypair } from "./derive-CY0En_Y3.js";
|
|
3
3
|
import { dirname } from "node:path";
|
|
4
4
|
import { buildCommand } from "@stricli/core";
|
|
5
5
|
import pc from "picocolors";
|
|
6
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
7
6
|
import { x402Client } from "@x402/fetch";
|
|
7
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
9
9
|
import { base58 } from "@scure/base";
|
|
10
10
|
import { toClientEvmSigner } from "@x402/evm";
|
|
@@ -12,10 +12,8 @@ import { registerExactEvmScheme } from "@x402/evm/exact/client";
|
|
|
12
12
|
import { createPublicClient, http } from "viem";
|
|
13
13
|
import { privateKeyToAccount } from "viem/accounts";
|
|
14
14
|
import { base } from "viem/chains";
|
|
15
|
-
import { SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, address, appendTransactionMessageInstructions, createDefaultRpcTransport, createSolanaRpcFromTransport, createTransactionMessage, getAddressEncoder, getBase64EncodedWireTransaction, getProgramDerivedAddress, isSolanaError, mainnet, partiallySignTransactionMessageWithSigners, pipe,
|
|
16
|
-
import {
|
|
17
|
-
import { TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
|
|
18
|
-
import { TOKEN_2022_PROGRAM_ADDRESS, fetchMint, findAssociatedTokenPda, getTransferCheckedInstruction } from "@solana-program/token-2022";
|
|
15
|
+
import { SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, address, appendTransactionMessageInstructions, createDefaultRpcTransport, createSolanaRpcFromTransport, createTransactionMessage, getAddressEncoder, getBase64EncodedWireTransaction, getProgramDerivedAddress, isSolanaError, mainnet, partiallySignTransactionMessageWithSigners, pipe, setTransactionMessageComputeUnitLimit, setTransactionMessageComputeUnitPrice, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash } from "@solana/kit";
|
|
16
|
+
import { TOKEN_PROGRAM_ADDRESS, findAssociatedTokenPda, getTransferCheckedInstruction } from "@solana-program/token";
|
|
19
17
|
//#region src/lib/output.ts
|
|
20
18
|
function isTTY() {
|
|
21
19
|
return !!process.stderr.isTTY;
|
|
@@ -32,6 +30,9 @@ function error(msg) {
|
|
|
32
30
|
function dim(msg) {
|
|
33
31
|
process.stderr.write(`${isTTY() ? pc.dim(msg) : msg}\n`);
|
|
34
32
|
}
|
|
33
|
+
function success(msg) {
|
|
34
|
+
process.stderr.write(`${isTTY() ? pc.green(`✓ ${msg}`) : `✓ ${msg}`}\n`);
|
|
35
|
+
}
|
|
35
36
|
function appendHistory(historyPath, record) {
|
|
36
37
|
try {
|
|
37
38
|
mkdirSync(dirname(historyPath), { recursive: true });
|
|
@@ -157,7 +158,7 @@ function formatTxLine(r, opts) {
|
|
|
157
158
|
//#region src/lib/optimized-svm-scheme.ts
|
|
158
159
|
const MEMO_PROGRAM_ADDRESS = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";
|
|
159
160
|
const COMPUTE_UNIT_LIMIT = 2e4;
|
|
160
|
-
const COMPUTE_UNIT_PRICE_MICROLAMPORTS =
|
|
161
|
+
const COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1n;
|
|
161
162
|
const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
162
163
|
const USDC_DECIMALS = 6;
|
|
163
164
|
const MAINNET_RPC_URLS = ["https://api.mainnet.solana.com", "https://public.rpc.solanavibestation.com"];
|
|
@@ -203,35 +204,24 @@ var OptimizedSvmScheme = class {
|
|
|
203
204
|
async createPaymentPayload(x402Version, paymentRequirements) {
|
|
204
205
|
const rpc = this.rpc;
|
|
205
206
|
const asset = paymentRequirements.asset;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (asset === USDC_MINT) {
|
|
209
|
-
tokenProgramAddress = TOKEN_PROGRAM_ADDRESS;
|
|
210
|
-
decimals = USDC_DECIMALS;
|
|
211
|
-
} else {
|
|
212
|
-
const tokenMint = await fetchMint(rpc, asset);
|
|
213
|
-
tokenProgramAddress = tokenMint.programAddress;
|
|
214
|
-
if (tokenProgramAddress !== TOKEN_PROGRAM_ADDRESS && tokenProgramAddress !== TOKEN_2022_PROGRAM_ADDRESS) throw new Error("Asset was not created by a known token program");
|
|
215
|
-
decimals = tokenMint.data.decimals;
|
|
216
|
-
}
|
|
217
|
-
const [sourceATA] = await findAssociatedTokenPda({
|
|
207
|
+
if (asset !== USDC_MINT) throw new Error(`Unsupported asset: ${asset}. Only USDC is supported.`);
|
|
208
|
+
const [[sourceATA], [destinationATA]] = await Promise.all([findAssociatedTokenPda({
|
|
218
209
|
mint: asset,
|
|
219
210
|
owner: this.signer.address,
|
|
220
|
-
tokenProgram:
|
|
221
|
-
})
|
|
222
|
-
const [destinationATA] = await findAssociatedTokenPda({
|
|
211
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS
|
|
212
|
+
}), findAssociatedTokenPda({
|
|
223
213
|
mint: asset,
|
|
224
214
|
owner: paymentRequirements.payTo,
|
|
225
|
-
tokenProgram:
|
|
226
|
-
});
|
|
215
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS
|
|
216
|
+
})]);
|
|
227
217
|
const transferIx = getTransferCheckedInstruction({
|
|
228
218
|
source: sourceATA,
|
|
229
219
|
mint: asset,
|
|
230
220
|
destination: destinationATA,
|
|
231
221
|
authority: this.signer,
|
|
232
222
|
amount: BigInt(paymentRequirements.amount),
|
|
233
|
-
decimals
|
|
234
|
-
}
|
|
223
|
+
decimals: USDC_DECIMALS
|
|
224
|
+
});
|
|
235
225
|
const feePayer = paymentRequirements.extra?.feePayer;
|
|
236
226
|
if (!feePayer) throw new Error("feePayer is required in paymentRequirements.extra for SVM transactions");
|
|
237
227
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
@@ -243,7 +233,7 @@ var OptimizedSvmScheme = class {
|
|
|
243
233
|
};
|
|
244
234
|
return {
|
|
245
235
|
x402Version,
|
|
246
|
-
payload: { transaction: getBase64EncodedWireTransaction(await partiallySignTransactionMessageWithSigners(pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageComputeUnitPrice(COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx), (tx) =>
|
|
236
|
+
payload: { transaction: getBase64EncodedWireTransaction(await partiallySignTransactionMessageWithSigners(pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageComputeUnitPrice(COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx), (tx) => setTransactionMessageComputeUnitLimit(COMPUTE_UNIT_LIMIT, tx), (tx) => setTransactionMessageFeePayer(feePayer, tx), (tx) => appendTransactionMessageInstructions([transferIx, memoIx], tx), (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx)))) }
|
|
247
237
|
};
|
|
248
238
|
}
|
|
249
239
|
};
|
|
@@ -544,4 +534,4 @@ const walletInfoCommand = buildCommand({
|
|
|
544
534
|
}
|
|
545
535
|
});
|
|
546
536
|
//#endregion
|
|
547
|
-
export { error as _, fetchTempoBalances as a,
|
|
537
|
+
export { error as _, fetchTempoBalances as a, success as b, resolveWallet as c, displayNetwork as d, formatAmount as f, dim as g, readHistory as h, fetchSolanaBalances as i, appendHistory as l, formatUsdcValue as m, fetchAllBalances as n, walletInfoCommand as o, formatTxLine as p, fetchEvmBalances as r, buildX402Client as s, balanceLine as t, calcSpend as u, info as v, warn as x, isTTY as y };
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,18 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "x402-proxy",
|
|
3
|
-
"name": "x402 Proxy",
|
|
4
|
-
"description": "x402
|
|
3
|
+
"name": "mpp/x402 Payments Proxy",
|
|
4
|
+
"description": "x402 and MPP payments, wallet tools, and paid inference proxying",
|
|
5
5
|
"version": "1.0.0",
|
|
6
|
+
"providers": ["surf"],
|
|
7
|
+
"autoEnableWhenConfiguredProviders": ["surf"],
|
|
8
|
+
"skills": ["skills"],
|
|
9
|
+
"contracts": {
|
|
10
|
+
"tools": ["x_wallet", "x_balance", "x_request", "x_payment"]
|
|
11
|
+
},
|
|
6
12
|
"configSchema": {
|
|
7
13
|
"type": "object",
|
|
14
|
+
"additionalProperties": false,
|
|
8
15
|
"properties": {
|
|
9
16
|
"providers": {
|
|
10
17
|
"type": "object",
|
|
11
|
-
"description": "Provider catalog keyed by name
|
|
18
|
+
"description": "Provider catalog keyed by name. Defaults to the built-in surf provider when omitted.",
|
|
19
|
+
"additionalProperties": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"properties": {
|
|
23
|
+
"baseUrl": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Gateway base path for this provider, typically under /x402-proxy"
|
|
26
|
+
},
|
|
27
|
+
"upstreamUrl": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "Upstream inference origin to proxy to"
|
|
30
|
+
},
|
|
31
|
+
"protocol": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"enum": ["x402", "mpp", "auto"],
|
|
34
|
+
"description": "Payment protocol for this provider. Defaults to mpp."
|
|
35
|
+
},
|
|
36
|
+
"mppSessionBudget": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "Maximum USDC budget to lock for MPP sessions for this provider (default: 0.5)"
|
|
39
|
+
},
|
|
40
|
+
"models": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"description": "Static OpenClaw model catalog entries for this provider"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"protocol": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": ["x402", "mpp", "auto"],
|
|
50
|
+
"description": "Default payment protocol fallback for providers that do not override it."
|
|
51
|
+
},
|
|
52
|
+
"mppSessionBudget": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Default maximum USDC budget to lock for MPP sessions (default: 0.5)"
|
|
12
55
|
},
|
|
13
56
|
"keypairPath": {
|
|
14
57
|
"type": "string",
|
|
15
|
-
"description": "Optional path to Solana keypair JSON file (overrides x402-proxy wallet resolution)"
|
|
58
|
+
"description": "Optional path to Solana keypair JSON file (overrides x402-proxy wallet resolution for Solana/x402 surfaces)"
|
|
16
59
|
},
|
|
17
60
|
"rpcUrl": {
|
|
18
61
|
"type": "string",
|
|
@@ -24,5 +67,27 @@
|
|
|
24
67
|
}
|
|
25
68
|
},
|
|
26
69
|
"required": []
|
|
70
|
+
},
|
|
71
|
+
"uiHints": {
|
|
72
|
+
"protocol": {
|
|
73
|
+
"label": "Default protocol",
|
|
74
|
+
"help": "Used only when a provider entry does not set its own protocol."
|
|
75
|
+
},
|
|
76
|
+
"mppSessionBudget": {
|
|
77
|
+
"label": "Default MPP budget",
|
|
78
|
+
"placeholder": "0.5"
|
|
79
|
+
},
|
|
80
|
+
"keypairPath": {
|
|
81
|
+
"label": "Solana keypair path",
|
|
82
|
+
"advanced": true
|
|
83
|
+
},
|
|
84
|
+
"rpcUrl": {
|
|
85
|
+
"label": "Solana RPC URL",
|
|
86
|
+
"advanced": true
|
|
87
|
+
},
|
|
88
|
+
"dashboardUrl": {
|
|
89
|
+
"label": "Dashboard URL",
|
|
90
|
+
"advanced": true
|
|
91
|
+
}
|
|
27
92
|
}
|
|
28
93
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x402-proxy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "curl for x402 paid APIs. Auto-pays any endpoint on Base, Solana, and Tempo. Also works as an OpenClaw plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,7 +20,18 @@
|
|
|
20
20
|
"openclaw": {
|
|
21
21
|
"extensions": [
|
|
22
22
|
"./dist/openclaw/plugin.js"
|
|
23
|
-
]
|
|
23
|
+
],
|
|
24
|
+
"providers": [
|
|
25
|
+
"surf"
|
|
26
|
+
],
|
|
27
|
+
"compat": {
|
|
28
|
+
"pluginApi": ">=2026.3.24",
|
|
29
|
+
"minGatewayVersion": "2026.3.24"
|
|
30
|
+
},
|
|
31
|
+
"build": {
|
|
32
|
+
"openclawVersion": "2026.3.24",
|
|
33
|
+
"pluginSdkVersion": "2026.3.24"
|
|
34
|
+
}
|
|
24
35
|
},
|
|
25
36
|
"bin": {
|
|
26
37
|
"x402-proxy": "./dist/bin/cli.js"
|
|
@@ -35,9 +46,7 @@
|
|
|
35
46
|
"@scure/bip32": "^2.0.1",
|
|
36
47
|
"@scure/bip39": "^2.0.1",
|
|
37
48
|
"@sinclair/typebox": "^0.34.48",
|
|
38
|
-
"@solana-program/compute-budget": "^0.15.0",
|
|
39
49
|
"@solana-program/token": "^0.12.0",
|
|
40
|
-
"@solana-program/token-2022": "^0.9.0",
|
|
41
50
|
"@solana/kit": "^6.5.0",
|
|
42
51
|
"@stricli/core": "^1.2.6",
|
|
43
52
|
"@x402/core": "^2.8.0",
|
package/skills/SKILL.md
CHANGED
|
@@ -41,6 +41,8 @@ npx x402-proxy https://api.example.com/data > response.json
|
|
|
41
41
|
|
|
42
42
|
```
|
|
43
43
|
x402-proxy <url> # paid HTTP request (default)
|
|
44
|
+
x402-proxy serve # local paid inference proxy server
|
|
45
|
+
x402-proxy claude # run Claude Code through paid local proxy
|
|
44
46
|
x402-proxy mcp <url> # MCP stdio proxy for AI agents
|
|
45
47
|
x402-proxy mcp add <name> <url> # install MCP server into AI client
|
|
46
48
|
x402-proxy setup # wallet onboarding wizard
|
|
@@ -174,7 +176,7 @@ openclaw plugins install x402-proxy
|
|
|
174
176
|
npx x402-proxy setup # creates wallet if needed
|
|
175
177
|
```
|
|
176
178
|
|
|
177
|
-
Registers: `
|
|
179
|
+
Registers: `x_wallet` tool, `x_request` tool (aliased as `x_balance`/`x_payment`), `/x_wallet` and `/x_send` commands, `/x402-proxy/*` HTTP route for inference proxying.
|
|
178
180
|
|
|
179
181
|
## Library API
|
|
180
182
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# OpenClaw Plugin Setup
|
|
2
2
|
|
|
3
|
-
x402-proxy ships as an [OpenClaw](https://openclaw.dev) plugin. Gives your gateway automatic x402 payment, wallet management, and pay-per-use inference proxying via Solana
|
|
3
|
+
x402-proxy ships as an [OpenClaw](https://openclaw.dev) plugin. Gives your gateway automatic x402 and MPP payment, wallet management, and pay-per-use inference proxying via USDC on Solana, Base, and Tempo.
|
|
4
4
|
|
|
5
5
|
## What it registers
|
|
6
6
|
|
|
7
|
-
- **`
|
|
8
|
-
- **`
|
|
9
|
-
- **`/x_wallet` command** - wallet status dashboard, `
|
|
10
|
-
- **
|
|
7
|
+
- **`x_wallet` tool** (alias: `x_balance`) - check wallet readiness, balances, and spend history for x402 and MPP payments
|
|
8
|
+
- **`x_request` tool** (alias: `x_payment`) - call a paid HTTP endpoint with automatic x402 or MPP settlement (params: `url`, `method`, `params`, `headers`, `protocol`)
|
|
9
|
+
- **`/x_wallet` command** - wallet status dashboard, `history [page]`
|
|
10
|
+
- **`/x_send` command** - send USDC with confirmation step (`/x_send <amount|all> <address>`, then `/x_send confirm`)
|
|
11
|
+
- **HTTP route `/x402-proxy/*`** - proxies requests to upstream inference endpoints with payment, tracks token usage and cost
|
|
11
12
|
|
|
12
13
|
## Step 1: Install the plugin
|
|
13
14
|
|
|
@@ -36,6 +37,15 @@ Or set an explicit keypair in plugin config (step 3).
|
|
|
36
37
|
|
|
37
38
|
## Step 3: Configure providers and models
|
|
38
39
|
|
|
40
|
+
If you do nothing, the plugin now defaults to:
|
|
41
|
+
|
|
42
|
+
- provider id: `surf`
|
|
43
|
+
- gateway base URL: `/x402-proxy/v1`
|
|
44
|
+
- upstream: `https://surf.cascade.fyi/api/v1/inference`
|
|
45
|
+
- protocol: `mpp`
|
|
46
|
+
|
|
47
|
+
You only need explicit config if you want to override the defaults or supply a custom model catalog.
|
|
48
|
+
|
|
39
49
|
Add the plugin config to your `openclaw.json` (or via `openclaw config edit`):
|
|
40
50
|
|
|
41
51
|
```json
|
|
@@ -46,7 +56,7 @@ Add the plugin config to your `openclaw.json` (or via `openclaw config edit`):
|
|
|
46
56
|
"config": {
|
|
47
57
|
"providers": {
|
|
48
58
|
"surf-inference": {
|
|
49
|
-
"baseUrl": "/x402/v1",
|
|
59
|
+
"baseUrl": "/x402-proxy/v1",
|
|
50
60
|
"upstreamUrl": "https://surf.cascade.fyi/api/v1/inference",
|
|
51
61
|
"models": [
|
|
52
62
|
{ "id": "anthropic/claude-opus-4.6", "name": "Claude Opus 4.6", "maxTokens": 200000, "reasoning": true, "input": ["text", "image"], "cost": { "input": 0.015, "output": 0.075, "cacheRead": 0.0015, "cacheWrite": 0.01875 }, "contextWindow": 200000 },
|
|
@@ -78,7 +88,7 @@ Add the plugin config to your `openclaw.json` (or via `openclaw config edit`):
|
|
|
78
88
|
|
|
79
89
|
| Field | Description |
|
|
80
90
|
|-------|-------------|
|
|
81
|
-
| `providers.<name>.baseUrl` | Route path registered in OpenClaw (e.g., `/x402/v1`) |
|
|
91
|
+
| `providers.<name>.baseUrl` | Route path registered in OpenClaw (e.g., `/x402-proxy/v1`) |
|
|
82
92
|
| `providers.<name>.upstreamUrl` | Actual upstream endpoint (e.g., `https://surf.cascade.fyi/api/v1/inference`) |
|
|
83
93
|
| `providers.<name>.models[]` | Model catalog array |
|
|
84
94
|
| `keypairPath` | Optional path to solana-keygen JSON file (overrides wallet resolution) |
|
|
@@ -111,8 +121,8 @@ openclaw models # verify models appear
|
|
|
111
121
|
|
|
112
122
|
1. Plugin boots, loads wallet via the resolution cascade
|
|
113
123
|
2. Registers each provider from config into OpenClaw's model catalog (API type: `openai-completions`, no auth required)
|
|
114
|
-
3. HTTP route `/x402/*` intercepts inference requests, strips prefix, proxies to `upstreamUrl`
|
|
115
|
-
4. On 402 response, auto-
|
|
124
|
+
3. HTTP route `/x402-proxy/*` intercepts inference requests, strips prefix, proxies to `upstreamUrl`
|
|
125
|
+
4. On 402 response, auto-pays via MPP (Tempo/Base) or x402 (Solana) depending on provider config
|
|
116
126
|
5. SSE streaming responses are parsed for token usage and logged to `~/.config/x402-proxy/history.jsonl`
|
|
117
127
|
6. Tools and command are available to all agents on the gateway
|
|
118
128
|
|
|
@@ -122,7 +132,7 @@ The model list on `surf.cascade.fyi` changes over time. Fetch the current catalo
|
|
|
122
132
|
|
|
123
133
|
```bash
|
|
124
134
|
npx x402-proxy --protocol mpp --network solana \
|
|
125
|
-
https://surf.cascade.fyi/api/v1/inference/models
|
|
135
|
+
https://surf.cascade.fyi/api/v1/inference/v1/models
|
|
126
136
|
```
|
|
127
137
|
|
|
128
138
|
Then update the `models` array in your plugin config accordingly.
|
|
@@ -131,5 +141,5 @@ Then update the `models` array in your plugin config accordingly.
|
|
|
131
141
|
|
|
132
142
|
- **Models don't appear in `openclaw models`** - the plugin uses a `catalog` hook (not `models` field). Make sure you're on x402-proxy >= 0.8.5.
|
|
133
143
|
- **"no wallet found" in logs** - run `npx x402-proxy setup` or set `X402_PROXY_WALLET_MNEMONIC` env var before starting the gateway.
|
|
134
|
-
- **402 errors on inference** - check wallet has USDC balance: use `
|
|
144
|
+
- **402 errors on inference** - check wallet has USDC balance: use `x_wallet` tool or `npx x402-proxy wallet`.
|
|
135
145
|
- **Gateway cold start slow** - normal on small VMs (~72s). The `x402-wallet` service eagerly loads the wallet during boot.
|
package/dist/setup-B6xRV8Ue.js
DELETED
package/dist/status-Bj3U-W2M.js
DELETED
package/dist/wallet-4C9EL4Iv.js
DELETED
|
File without changes
|