@warppay402/server 1.1.0 → 1.1.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/dist/examples/basic-monetized-server.js +2 -2
- package/dist/mcpWrapper.js +1 -1
- package/dist/monetize.js +1 -1
- package/dist/pay_client.js +12 -9
- package/dist/server.js +2 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +6 -2
|
@@ -4,11 +4,11 @@ import { monetize } from "../index.js";
|
|
|
4
4
|
import { Hono } from "hono";
|
|
5
5
|
const app = new Hono();
|
|
6
6
|
// Define the developer's wallet address (where 99.5% of funds go)
|
|
7
|
-
const developerWallet = "
|
|
7
|
+
const developerWallet = "0xYOUR_NEW_WALLET_ADDRESS";
|
|
8
8
|
app.use("/api/weather", monetize({
|
|
9
9
|
price: "0.01",
|
|
10
10
|
payTo: developerWallet,
|
|
11
|
-
platformWallet: "
|
|
11
|
+
platformWallet: "0xYOUR_NEW_WALLET_ADDRESS",
|
|
12
12
|
platformFeeBps: 50,
|
|
13
13
|
facilitatorUrl: "https://warppay402.com"
|
|
14
14
|
}));
|
package/dist/mcpWrapper.js
CHANGED
|
@@ -2,7 +2,7 @@ import { MemoryNonceStore } from "./monetize";
|
|
|
2
2
|
const DEFAULT_USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
3
3
|
const DEFAULT_NETWORK = "eip155:8453";
|
|
4
4
|
const DEFAULT_FACILITATOR = "https://warppay402.com";
|
|
5
|
-
const DEFAULT_PLATFORM_WALLET = "
|
|
5
|
+
const DEFAULT_PLATFORM_WALLET = "0xYOUR_NEW_WALLET_ADDRESS";
|
|
6
6
|
const defaultMemoryStore = new MemoryNonceStore();
|
|
7
7
|
function parseTokenUnits(priceStr) {
|
|
8
8
|
const normalized = String(priceStr).trim();
|
package/dist/monetize.js
CHANGED
|
@@ -55,7 +55,7 @@ const defaultMemoryStore = new MemoryNonceStore();
|
|
|
55
55
|
const DEFAULT_USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
56
56
|
const DEFAULT_NETWORK = "eip155:8453";
|
|
57
57
|
const DEFAULT_FACILITATOR = "https://warppay402.com";
|
|
58
|
-
const DEFAULT_PLATFORM_WALLET = "
|
|
58
|
+
const DEFAULT_PLATFORM_WALLET = "0xYOUR_NEW_WALLET_ADDRESS";
|
|
59
59
|
function toBase64(str) {
|
|
60
60
|
const bytes = new TextEncoder().encode(str);
|
|
61
61
|
let binary = "";
|
package/dist/pay_client.js
CHANGED
|
@@ -6,13 +6,13 @@ if (!PRIVATE_KEY) {
|
|
|
6
6
|
console.error("Please set process.env.PRIVATE_KEY");
|
|
7
7
|
process.exit(1);
|
|
8
8
|
}
|
|
9
|
-
const account = privateKeyToAccount(PRIVATE_KEY);
|
|
9
|
+
const account = privateKeyToAccount(PRIVATE_KEY.startsWith("0x") ? PRIVATE_KEY : `0x${PRIVATE_KEY}`);
|
|
10
10
|
const walletClient = createWalletClient({
|
|
11
11
|
account,
|
|
12
12
|
chain: base,
|
|
13
13
|
transport: http("https://mainnet.base.org")
|
|
14
14
|
});
|
|
15
|
-
const API_URL = process.env.API_URL || "http://localhost:
|
|
15
|
+
const API_URL = process.env.API_URL || "http://localhost:3005/public_data_feed/base-usdc-token-contract.json";
|
|
16
16
|
async function executeAgentPayment() {
|
|
17
17
|
console.log(`[Agent] Probing endpoint: ${API_URL}`);
|
|
18
18
|
// Step 1: Retrieve 402 challenge
|
|
@@ -27,7 +27,9 @@ async function executeAgentPayment() {
|
|
|
27
27
|
}
|
|
28
28
|
const challenge = JSON.parse(atob(paymentRequiredHeader));
|
|
29
29
|
const requirement = challenge.accepts[0];
|
|
30
|
-
|
|
30
|
+
// Resolve amount safely (default to 1000 base units / 0.001 USDC if undefined)
|
|
31
|
+
const baseUnits = BigInt(requirement.amount || "1000");
|
|
32
|
+
console.log(`[Agent] Payment required: $${Number(baseUnits) / 1e6} USDC on Base`);
|
|
31
33
|
// Step 2: Sign EIP-712 payment authorization
|
|
32
34
|
const domain = {
|
|
33
35
|
name: "USD Coin",
|
|
@@ -49,12 +51,13 @@ async function executeAgentPayment() {
|
|
|
49
51
|
const nonce = `0x${Array.from(crypto.getRandomValues(new Uint8Array(32)))
|
|
50
52
|
.map((b) => b.toString(16).padStart(2, "0"))
|
|
51
53
|
.join("")}`;
|
|
54
|
+
const maxTimeout = requirement.maxTimeoutSeconds || 300;
|
|
52
55
|
const authorization = {
|
|
53
56
|
from: account.address,
|
|
54
57
|
to: requirement.payTo,
|
|
55
|
-
value:
|
|
58
|
+
value: baseUnits.toString(),
|
|
56
59
|
validAfter: (now - 60).toString(),
|
|
57
|
-
validBefore: (now +
|
|
60
|
+
validBefore: (now + maxTimeout).toString(),
|
|
58
61
|
nonce
|
|
59
62
|
};
|
|
60
63
|
const signatureHex = await walletClient.signTypedData({
|
|
@@ -64,13 +67,13 @@ async function executeAgentPayment() {
|
|
|
64
67
|
message: {
|
|
65
68
|
from: account.address,
|
|
66
69
|
to: requirement.payTo,
|
|
67
|
-
value:
|
|
70
|
+
value: baseUnits,
|
|
68
71
|
validAfter: BigInt(now - 60),
|
|
69
|
-
validBefore: BigInt(now +
|
|
72
|
+
validBefore: BigInt(now + maxTimeout),
|
|
70
73
|
nonce
|
|
71
74
|
}
|
|
72
75
|
});
|
|
73
|
-
// Step 3: Construct
|
|
76
|
+
// Step 3: Construct payment payload
|
|
74
77
|
const paymentSignaturePayload = JSON.stringify({
|
|
75
78
|
x402Version: 2,
|
|
76
79
|
scheme: "exact",
|
|
@@ -89,6 +92,6 @@ async function executeAgentPayment() {
|
|
|
89
92
|
});
|
|
90
93
|
const responseData = await paidRes.json();
|
|
91
94
|
console.log(`[Server Status]: ${paidRes.status}`);
|
|
92
|
-
console.log("[Server Payload]:", responseData);
|
|
95
|
+
console.log("[Server Payload]:", JSON.stringify(responseData, null, 2));
|
|
93
96
|
}
|
|
94
97
|
executeAgentPayment().catch(console.error);
|
package/dist/server.js
CHANGED
|
@@ -4,7 +4,7 @@ import { monetize } from "./monetize.js";
|
|
|
4
4
|
import { Hono } from "hono";
|
|
5
5
|
const app = new Hono();
|
|
6
6
|
// Define the developer's wallet address (where 99.5% of funds go)
|
|
7
|
-
const developerWallet = "
|
|
7
|
+
const developerWallet = "0xYOUR_NEW_WALLET_ADDRESS";
|
|
8
8
|
// 1. PUBLIC HEALTH & MCP DISCOVERY ROUTES (No 402 Payment Required)
|
|
9
9
|
app.get("/", (c) => c.json({ status: "ok", service: "WarpPay402 Gateway" }));
|
|
10
10
|
app.get("/health", (c) => c.json({ status: "healthy" }));
|
|
@@ -65,7 +65,7 @@ app.post("/mcp", async (c) => {
|
|
|
65
65
|
app.use("/api/weather", monetize({
|
|
66
66
|
price: "0.01",
|
|
67
67
|
payTo: developerWallet,
|
|
68
|
-
platformWallet: "
|
|
68
|
+
platformWallet: "0xYOUR_NEW_WALLET_ADDRESS",
|
|
69
69
|
platformFeeBps: 50,
|
|
70
70
|
facilitatorUrl: "https://warppay402.com"
|
|
71
71
|
}));
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "warppay402-server",
|
|
3
3
|
"name": "warppay402-server",
|
|
4
4
|
"version": "1.1.0",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Self-hosted x402 monetization server for MCP tools and HTTP APIs: Non-custodial, multi-chain payments across Base Mainnet and Solana L1.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"type": "mcp-server",
|
|
8
8
|
"config": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warppay402/server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Instant MCP Tool & x402 Monetization SDK for Cloudflare Gateway and Base",
|
|
5
5
|
"homepage": "https://www.warppay402.com",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,7 +38,11 @@
|
|
|
38
38
|
"hono",
|
|
39
39
|
"ai-agents",
|
|
40
40
|
"warppay402",
|
|
41
|
-
"solana"
|
|
41
|
+
"solana",
|
|
42
|
+
"middleware",
|
|
43
|
+
"cloudfare",
|
|
44
|
+
"ai-agents",
|
|
45
|
+
"model-context-protocal"
|
|
42
46
|
],
|
|
43
47
|
"repository": {
|
|
44
48
|
"type": "git",
|