@stableyard/x402plus
v2.0.0
Published
x402plus — HTTP 402 payments with multi-chain support (EVM, Solana, Movement) and intent-based payments via Stableyard GRID ID
Downloads
99
Maintainers
Readme
x402plus
Pay for any API, from any chain, with one signature.
x402plus extends the x402 protocol with multi-chain support (EVM, Solana, Movement) and intent-based gasless payments via Stableyard GRID ID.
x402 GET /api -> 402 -> sign USDC transfer -> pay on-chain -> 200
x402plus GET /api -> 402 -> sign intent -> settle off-chain -> 200Install
npm install @stableyard/x402plusBackend — monetize an API in 2 lines
import { x402plus } from "@stableyard/x402plus";
app.use(x402plus("0xYourAddress", {
"GET /api/premium": 0.10, // $0.10 per request
"POST /api/generate": 5.00, // $5.00 per generation
}));No facilitator URL needed. No USDC addresses. No chain config. Just a wallet address and dollar amounts.
Multi-chain support
app.use(x402plus("0xYourAddress", {
"GET /api/premium": 0.10,
}, {
defaultChain: "polygon",
solana: { payTo: "YourSolanaAddress" },
movement: { payTo: "0x00...YourMovementAddress" },
}));Custom facilitator
app.use(x402plus("0xYourAddress", routes, "https://your-facilitator.com"));Client — pay for an API
import { withPayments } from "@stableyard/x402plus/client";
const paidFetch = withPayments(window.ethereum);
const res = await paidFetch("https://api.example.com/premium");Payment schemes
Every 402 response offers multiple schemes. Clients choose based on what they have:
| | exact EVM | exact Solana | exact Movement | intent (GRID ID) |
|---|---|---|---|---|
| Signs | EIP-3009 | Solana Transaction | Aptos BCS | EIP-712 intent |
| Settlement | On-chain | On-chain | On-chain | Off-chain |
| Gas | Facilitator pays | Facilitator pays | Payer pays | Zero |
Networks
| Network | Exact | Intent | Asset | |---------|-------|--------|-------| | Ethereum, Base, Polygon, Arbitrum, Optimism | Yes | Yes | USDC | | Solana, Solana Devnet | Yes | -- | USDC / SOL | | Movement, Movement Testnet | Yes | -- | USDC.e / MOVE |
Exports
// Middleware (backend)
import { x402plus } from "@stableyard/x402plus";
// Client (frontend)
import { withPayments, createGridClient } from "@stableyard/x402plus/client";
// Types
import type { PaymentRequirements, Signer } from "@stableyard/x402plus/types";
// Facilitator client
import { createHttpFacilitatorClient } from "@stableyard/x402plus/facilitator";Debug
Set DEBUG_X402=true to enable verbose logging.
Links
- x402.org — The base x402 protocol
- Stableyard — GRID ID infrastructure
- Integration Guide
License
Apache-2.0
