Skip to content

BackTrackCo/x402r-sdk

x402r-sdk

TypeScript SDK for x402r refundable payments on EVM chains.

Packages

Package Description
@x402r/sdk Client factory, role presets, action groups
@x402r/core Types, ABIs, config, raw actions, deploy utils
@x402r/helpers Payment option builder for x402 HTTP 402 flows

Install

pnpm add @x402r/sdk

@x402r/sdk re-exports everything from @x402r/core.

Quick example

import { createPublicClient, createWalletClient, http } from 'viem'
import { baseSepolia } from 'viem/chains'
import { createX402r } from '@x402r/sdk'

const publicClient = createPublicClient({ chain: baseSepolia, transport: http() })
const walletClient = createWalletClient({ chain: baseSepolia, transport: http() })

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

// paymentInfo identifies a payment (payer, receiver, token, amount, operator)
const state = await x402r.payment.getState(paymentInfo)
const config = await x402r.operator.getConfig()

Supported chains

Base · Base Sepolia

The SDK points at the canonical commerce-payments@v1.0.0 AuthCaptureEscrow, which lives on those two chains today; other EVMs return as the canonical primitives extend coverage. See packages/core/src/config for the full registry.

Development

pnpm install        # install dependencies
pnpm build          # build all packages
pnpm test           # run unit tests
pnpm test:fork      # run fork tests (requires Foundry)
pnpm typecheck      # type-check all packages
pnpm check          # biome lint + format check
pnpm format         # auto-fix lint + format

Package details

  • @x402r/sdk — client factory, role presets, action groups → README
  • @x402r/core — types, ABIs, raw actions, deploy utils → README
  • @x402r/helpers — payment option builder → README

Docs

docs.x402r.org

Contributing

See CONTRIBUTING.md.

License

Apache-2.0

About

SDK for the X402r refundable payments protocol

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages