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

@t402/wdk-protocol

v2.9.0

Published

T402 payment protocol for Tether WDK wallet apps

Readme

@t402/wdk-protocol

T402 payment protocol integration for the WDK wallet apps.

Installation

pnpm add @t402/wdk-protocol

Peer dependencies:

pnpm add @tetherto/wdk viem

Usage

import { T402Protocol } from '@t402/wdk-protocol';
import { T402WDK } from '@t402/wdk';

const wdk = new T402WDK(seedPhrase, { arbitrum: rpcUrl });
const t402 = await T402Protocol.create(wdk, {
  chains: ['ethereum', 'arbitrum'],
});

// Auto-pay for HTTP 402 resources
const { response, receipt } = await t402.fetch('https://api.example.com/premium');
console.log('Status:', response.status);
if (receipt) {
  console.log('Paid:', receipt.amount, 'on', receipt.network);
}

Step-by-step Payment

// 1. Get payment requirements
const requirements = await t402.getRequirements('https://api.example.com/premium');

// 2. Sign the payment
const payload = await t402.signPayment(requirements);

// 3. Submit with signed payment header
const response = await t402.submitPayment(
  'https://api.example.com/premium',
  payload,
);

API

T402Protocol.create(wdk, config?)

Async factory that initializes the protocol with EVM signer registration and chain family detection.

T402Protocol

| Method | Returns | Description | |--------|---------|-------------| | fetch(url, init?) | Promise<T402FetchResult> | Fetch with automatic 402 payment handling | | getRequirements(url, init?) | Promise<PaymentRequired> | Extract payment requirements from a 402 response | | signPayment(paymentRequired) | Promise<PaymentPayload> | Sign a payment using the registered mechanism | | submitPayment(url, payload, init?) | Promise<Response> | Submit a request with a pre-signed payment | | canHandleNetwork(network) | boolean | Check if a CAIP-2 network is supported | | getChains() | string[] | List configured chains | | getRegisteredFamilies() | Set<string> | Registered chain families (evm, ton, solana, ...) | | getHttpClient() | t402HTTPClient | Underlying t402 HTTP client | | getWdk() | T402WDK | Underlying WDK instance |

Chain Detection Utilities

  • detectChainFamily(network) -- CAIP-2 to chain family (e.g. "eip155:42161" -> "evm")
  • detectChainFamilyFromName(name) -- Chain name to family (e.g. "arbitrum" -> "evm")
  • isEvmNetwork(network) -- Check if CAIP-2 network is EVM
  • getEvmChainName(network) -- CAIP-2 to chain name (e.g. "eip155:42161" -> "arbitrum")
  • EVM_CHAIN_MAP -- Map of chain names to CAIP-2 identifiers

HTTP Utilities

  • extractPaymentRequired(response) -- Parse payment-required or x-payment header from a 402 response

Related Packages

License

Apache-2.0

Trademark Notice

T402 is an independent open-source project. It is not affiliated with, endorsed by, sponsored by, or in any way officially connected with Tether Operations Limited, Tether Holdings, or any of their affiliates.

"Tether", "USDT", "USDT0", "USDC", and other token names and trademarks referenced are the property of their respective owners and are used nominatively to describe token interoperability or to reference public open-source products (Apache 2.0). Compatibility with Tether's open-source WDK is at the user's option and does not represent a formal partnership.