Pay any HTTP 402 merchant on any chain. Auto-detects x402 or MPP, bridges funds via Across.
npm install universal-pay
import { createUniversalFetchWithAcross } from 'universal-pay'
const client = createUniversalFetchWithAcross({
privateKey: process.env.UNIVERSAL_PAY_KEY as `0x${string}`,
})
// Pays automatically — detects protocol, bridges if needed
const response = await client.fetch('https://merchant.example.com')
402 Payment RequiredPAYMENT-REQUIRED = x402, WWW-Authenticate = MPPcreateUniversalFetchWithAcross({
privateKey: process.env.UNIVERSAL_PAY_KEY as `0x${string}`, // required
polyfill: false, // replace globalThis.fetch (default: false)
across: {
originChainIds: [42161, 8453], // chains to scan for funds
rpcs: { 42161: 'https://...' }, // custom RPCs
},
})
MIT