
以 HTTP 402 Payment Required 为信号,使用稳定币(USDC)完成按次/按量付费访问,面向 API、网页与 AI 代理。
简单、快速、安全的 HTTP 402 支付协议实现
灵活的定价,随时升级,按需付费
fetch(endpoint, { method })
.then(r => r.status === 402 ? r.json() : r)
.then(async meta => {
// meta: { amount: 0.25, token: 'USDC', chain: 'BNB', to: '0x...' }
await wallet.pay(meta);
return fetch(endpoint, { method });
})
.then(r => r.json())
.then(data => console.log('OK', data));