No build · no backend · no npm

# x402 payments in a
<script> tag.

PipRail is one TypeScript SDK for "402 Payment Required" crypto payments. It runs right here in this browser — loaded from a CDN, nothing installed. The demo below is live.

⏳ loading @piprail/sdk from jsDelivr…

## The whole 402 loop, live in your browser

Pick what a merchant charges. PipRail builds the real x402 402 Payment Required challenge here, from your wallet address alone (no key) — then an agent reads it and prices the payment. No network calls, no keys.

Chain
Token
Amount
Pay to (your wallet — edit me)
402 what the merchant serves — built in-browser

    click "Run the 402 loop"…

🤖 what the paying agent sees — PipRailClient.quote()
…then the agent prices it here.

## One import, no build

A plain HTML page pays a gated URL — the SDK and any chain library resolve from the CDN on demand.

    <script type="module">
      import { PipRailClient } from 'https://esm.sh/@piprail/sdk'

      // In a browser, sign with the visitor's wallet (e.g. MetaMask) — never a raw key.
      const client = new PipRailClient({ chain: 'base', wallet: { walletClient } })
      const res = await client.fetch('https://api.example.com/paid')  // 402 → pays → 200
    </script>

⚠ Never put a raw private key in a browser page — the source is public. Sign with the visitor's injected wallet (a viem walletClient). Raw keys belong only in a server's environment. The merchant gate needs only an address, so it's safe anywhere.