@puga-labs/x402-mantle-sdk 0.4.1 → 0.4.2

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.
Files changed (2) hide show
  1. package/README.md +29 -15
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@puga-labs/x402-mantle-sdk.svg)](https://www.npmjs.com/package/@puga-labs/x402-mantle-sdk)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- SDK for x402 payments on Mantle blockchain. Protect your APIs with USDC payments using a simple middleware.
6
+ SDK for gasless x402 payments on Mantle blockchain using USDC (EIP-3009). Protect your APIs with crypto payments users sign, facilitator pays gas.
7
7
 
8
8
  ## Installation
9
9
 
@@ -30,9 +30,8 @@ npm install @puga-labs/x402-mantle-sdk
30
30
  import { useMantleX402 } from '@puga-labs/x402-mantle-sdk/react';
31
31
 
32
32
  function PaymentButton() {
33
- const { postWithPayment } = useMantleX402({
34
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz'
35
- });
33
+ // facilitatorUrl auto-detected from backend 402 response
34
+ const { postWithPayment } = useMantleX402();
36
35
 
37
36
  const handlePay = async () => {
38
37
  try {
@@ -87,9 +86,8 @@ function WalletConnect() {
87
86
  ```typescript
88
87
  import { createMantleClient } from '@puga-labs/x402-mantle-sdk/client';
89
88
 
90
- // Create client
89
+ // Create client (facilitatorUrl auto-detected from backend)
91
90
  const client = createMantleClient({
92
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz',
93
91
  resourceUrl: 'https://your-api.com',
94
92
  getProvider: () => window.ethereum,
95
93
  getAccount: () => userAddress
@@ -108,9 +106,9 @@ For full control over the payment flow:
108
106
  ```typescript
109
107
  import { createPaymentClient } from '@puga-labs/x402-mantle-sdk/client';
110
108
 
109
+ // Low-level client (facilitatorUrl auto-detected from backend)
111
110
  const paymentClient = createPaymentClient({
112
111
  resourceUrl: 'https://your-api.com',
113
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz',
114
112
  provider: window.ethereum,
115
113
  userAddress: '0x...' // Optional
116
114
  });
@@ -133,11 +131,11 @@ import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/express';
133
131
  const app = express();
134
132
  app.use(express.json());
135
133
 
136
- // Create paywall middleware
134
+ // Create paywall middleware (hosted mode - facilitatorUrl auto-detected)
137
135
  const pay = mantlePaywall({
138
136
  priceUsd: 0.01,
139
137
  payTo: '0xYourWalletAddress',
140
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz'
138
+ projectKey: 'pk_xxx' // Get from https://x402mantlesdk.xyz/dashboard
141
139
  });
142
140
 
143
141
  // Protected route
@@ -165,7 +163,7 @@ import { NextRequest, NextResponse } from 'next/server';
165
163
  const pay = mantlePaywall({
166
164
  priceUsd: 0.01,
167
165
  payTo: '0xYourWalletAddress',
168
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz'
166
+ projectKey: 'pk_xxx' // Get from dashboard
169
167
  });
170
168
 
171
169
  export const POST = pay(async (req: NextRequest) => {
@@ -186,7 +184,7 @@ const app = new Hono();
186
184
  const pay = mantlePaywall({
187
185
  priceUsd: 0.01,
188
186
  payTo: '0xYourWalletAddress',
189
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz'
187
+ projectKey: 'pk_xxx' // Get from dashboard
190
188
  });
191
189
 
192
190
  app.post('/api/generate', pay(async (c) => {
@@ -205,7 +203,7 @@ import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/web';
205
203
  const pay = mantlePaywall({
206
204
  priceUsd: 0.01,
207
205
  payTo: '0xYourWalletAddress',
208
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz'
206
+ projectKey: 'pk_xxx' // Get from dashboard
209
207
  });
210
208
 
211
209
  export default {
@@ -231,7 +229,7 @@ import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/web';
231
229
  const pay = mantlePaywall({
232
230
  priceUsd: 0.01,
233
231
  payTo: '0xYourWalletAddress',
234
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz'
232
+ projectKey: 'pk_xxx' // Get from dashboard
235
233
  });
236
234
 
237
235
  Deno.serve(pay(async (req) => {
@@ -317,7 +315,7 @@ The `facilitatorSecret` is **required** for self-hosted facilitators to prevent
317
315
 
318
316
  Create a facilitator with:
319
317
  ```bash
320
- npx create-mantle-facilitator my-facilitator
318
+ npx create-mantle-facilitator
321
319
  ```
322
320
 
323
321
  After setup, copy `FACILITATOR_SECRET` from the generated `.env` file to your backend's environment variables.
@@ -332,7 +330,6 @@ Track payments with built-in analytics:
332
330
  const pay = mantlePaywall({
333
331
  priceUsd: 0.01,
334
332
  payTo: '0x...',
335
- facilitatorUrl: 'https://facilitator.x402mantlesdk.xyz',
336
333
  projectKey: 'pk_xxx', // Get from dashboard - used for both billing AND analytics
337
334
 
338
335
  // Optional: Advanced telemetry config
@@ -429,6 +426,23 @@ import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/web';
429
426
  |---------|----------|--------------|----------|
430
427
  | Mantle Mainnet | 5000 | `0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9` | 6 |
431
428
 
429
+ ## Supported Tokens
430
+
431
+ Currently, the SDK supports **USDC only** for gasless payments.
432
+
433
+ ### Why only USDC?
434
+
435
+ Gasless payments via facilitator require tokens that implement the **EIP-3009** standard (`transferWithAuthorization`). This standard allows users to sign a payment authorization off-chain, while the facilitator submits the transaction and pays gas fees.
436
+
437
+ On Mantle mainnet, **USDC is currently the only token** that implements EIP-3009. As other stablecoins and tokens adopt this standard, we will add support for them in the SDK and facilitator.
438
+
439
+ | Token | EIP-3009 Support | Status |
440
+ |-------|------------------|--------|
441
+ | USDC | Yes | Supported |
442
+ | USDT | No | Not available |
443
+ | DAI | No | Not available |
444
+ | Other tokens | — | Pending EIP-3009 adoption |
445
+
432
446
  ### Price Conversion
433
447
 
434
448
  - `priceUsd: 0.01` = 1 cent = 10,000 atomic units
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puga-labs/x402-mantle-sdk",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "x402 payments SDK for Mantle (USDC, gasless, facilitator-based)",
5
5
  "license": "MIT",
6
6
  "author": "Evgenii Pugachev <cyprus.pugamuga@gmail.com>",