npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@x402r/sdk

v0.1.0

Published

Client SDK for x402r refundable payments. Wraps `@x402r/core` with a viem-style client.

Readme

@x402r/sdk

Client SDK for x402r refundable payments. Wraps @x402r/core with a viem-style client.

Install

pnpm add @x402r/sdk

Usage

Generic client

import { createX402r } from '@x402r/sdk'

const x402r = createX402r({
  publicClient,
  walletClient,
  operatorAddress: '0x…',
})

const amounts = await x402r.payment.getAmounts(paymentInfo)
const txHash = await x402r.refund.request(paymentInfo, amount, nonce)

Role preset

import { createPayerClient } from '@x402r/sdk'

const payer = createPayerClient({ publicClient, walletClient, operatorAddress: '0x…' })
// payer.payment only exposes getState and getAmounts — narrowed at the type level

Role presets (createPayerClient, createMerchantClient, createArbiterClient) provide type narrowing only. Permissions are enforced on-chain via canExecute().

Action groups

The client organizes operations into action groups by protocol domain:

  • paymentauthorize, charge, release, refundInEscrow, refundPostEscrow, approvePostEscrowRefund, getPostEscrowRefundAllowance, getState, getAmounts
  • refund — dispute lifecycle: request, cancel, deny, refuse, approveWithSignature, and read helpers (requires refundRequestAddress)
  • evidencesubmit, get, getBatch, count
  • escrowisDuringEscrow, getAuthorizationTime, getDuration (requires escrowPeriodAddress)
  • freezefreeze, unfreeze, isFrozen (requires freezeAddress)
  • operatorgetConfig, getFeeAddresses, calculateFees, distributeFees
  • watchonPayment, onRefundRequest, onFeeDistribution

Extending

.extend() adds new namespaces to the client — inspired by viem's extend pattern. The extension function receives the base client and returns an object whose keys become top-level properties, fully typed and chainable.

import { escrowPeriodActions } from '@x402r/sdk/plugins'

const x402r = createX402r({ publicClient, walletClient, operatorAddress: '0x…' })
  .extend(escrowPeriodActions('0xEscrowPeriod…'))
  .extend((client) => ({
    disputes: {
      async submitEvidence(
        paymentInfo: PaymentInfo,
        nonce: bigint,
        evidence: { name: string; description: string },
        ipfsUpload: (data: string) => Promise<string>,
      ) {
        const cid = await ipfsUpload(JSON.stringify(evidence))
        return client.evidence.submit(paymentInfo, nonce, cid)
      },
      async resolve(paymentInfo: PaymentInfo, nonce: bigint, ruling: 'refund' | 'deny') {
        if (ruling === 'refund') {
          const { refundableAmount } = await client.payment.getAmounts(paymentInfo)
          return client.payment.refundInEscrow(paymentInfo, refundableAmount)
        }
        return client.refund.deny(paymentInfo, nonce)
      },
    },
  }))

await x402r.escrow!.isDuringEscrow(paymentInfo)
await x402r.disputes.submitEvidence(
  paymentInfo, 0n,
  { name: 'Missing delivery', description: '...' },
  pinataUpload,
)
await x402r.disputes.resolve(paymentInfo, 0n, 'refund')

Shipped plugins (escrowPeriodActions, freezeActions) fill optional escrow/freeze slots. Custom extensions can add any namespace. Extensions cannot override defined base keys.

Refund & Dispute Flow

Non-obvious behaviors integrators should be aware of:

  1. Evidence is 1:1 with RefundRequest — each RefundRequest gets its own factory-deployed Evidence contract. Different arbiter = different contracts = separate evidence stores. Evidence is required when refund is configured (refundRequestEvidenceAddress must be provided alongside refundRequestAddress).

  2. approve() is cumulative and immediate — each call adds to approvedAmount and atomically executes refundInEscrow(). No undo. Amount is uint120 (max ~1.3e36).

  3. Evidence access control — arbiter identity comes from REFUND_REQUEST.ARBITER(), not from the operator's condition tree. If arbiter is a multisig, that address must call submitEvidence().

  4. Post-escrow refunds bypass RefundRequest — receiver can call refundPostEscrow() directly via the Receiver singleton condition. No arbiter involvement.

  5. Freeze roles — payer freezes (time extension near deadline), arbiter unfreezes (investigation resolved).

  6. payment.refundInEscrow is gated — on marketplace operators, only the RefundRequest contract can call it (via StaticAddressCondition). Use refund.approve() on role clients instead.

Docs

docs.x402r.org

License

Apache-2.0