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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tachiprotocol/sdk

v2.0.1

Published

TypeScript SDK for Tachi Protocol - pay-per-crawl access with automatic USDC micropayments

Readme

Tachi SDK

npm version License: MIT

TypeScript SDK for the Tachi Protocol - enabling pay-per-crawl access to web content with automatic USDC micropayments on Base.

Installation

npm install @tachiprotocol/sdk

Quick Start

import { TachiSDK } from '@tachiprotocol/sdk';

const sdk = new TachiSDK({
  network: 'base',
  rpcUrl: 'https://mainnet.base.org',
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
  usdcAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
  paymentProcessorAddress: '0xF09C29E5d3a12c0A766e6Dc65E2cb42CCf080abA'
});

// Fetch with automatic payment
const result = await sdk.fetch('https://gateway.tachi.ai/article/ai-training');

console.log(result.content); // Protected content
console.log(result.transactionHash); // Payment tx hash

Features

  • 🔄 Automatic 402 Detection - Detects payment-required responses
  • 💸 Auto-Payment - Pays via USDC on Base L2
  • Instant Settlement - ~2 second finality
  • 🔒 Verifiable Logs - All payments recorded on-chain
  • 🛡️ Type-Safe - Full TypeScript support

API Reference

new TachiSDK(config)

Create a new SDK instance.

Config:

  • network: 'base' or 'base-sepolia'
  • rpcUrl: Base RPC endpoint URL
  • privateKey: Your wallet's private key (as 0x${string})
  • usdcAddress: USDC contract address on Base
  • paymentProcessorAddress: Tachi PaymentProcessor address
  • debug?: Enable debug logging (optional)

sdk.fetch(url, options?)

Fetch content with automatic payment handling.

Returns: Promise<TachiResponse>

interface TachiResponse {
  content: string;
  statusCode: number;
  headers: Record<string, string>;
  paymentRequired: boolean;
  paymentAmount?: string;
  transactionHash?: Hash;
}

sdk.getBalance()

Get your USDC balance.

Returns: Promise<{wei: bigint, formatted: string}>

sdk.getAddress()

Get your wallet address.

Returns: Address

Advanced Usage

Custom Headers

const result = await sdk.fetch('https://api.example.com/data', {
  method: 'GET',
  headers: {
    'X-Custom-Header': 'value'
  }
});

Error Handling

try {
  const result = await sdk.fetch(url);
} catch (error) {
  if (error.message.includes('Insufficient USDC')) {
    console.log('Top up your USDC balance');
  }
}

Environment Variables

For security, store your private key in environment variables:

# .env
PRIVATE_KEY=your_private_key_here
BASE_RPC_URL=https://mainnet.base.org

Then load it:

import 'dotenv/config';
import { TachiSDK } from '@tachiprotocol/sdk';

const sdk = new TachiSDK({
  network: 'base',
  rpcUrl: process.env.BASE_RPC_URL!,
  privateKey: `0x${process.env.PRIVATE_KEY}` as `0x${string}`,
  // ... other config
});

Network Addresses

Base Mainnet

  • USDC: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
  • PaymentProcessor: 0xF09C29E5d3a12c0A766e6Dc65E2cb42CCf080abA

Base Sepolia (Testnet)

  • USDC: 0x036CbD53842c5426634e7929541eC2318f3dCF7e
  • PaymentProcessor: 0xF09C29E5d3a12c0A766e6Dc65E2cb42CCf080abA

Examples

See the demo.mjs in the main repo for a complete example.

License

MIT

Links