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

@tbusd/escrow-sdk

v0.3.2

Published

Trustless escrow API for crypto payments - programmatic smart contract escrow on Base

Downloads

270

Readme

@tbusd/escrow-sdk

SDK for TBUSD escrow contracts on Base. Perfect for AI agents, bots, and applications.

Installation

npm install @tbusd/escrow-sdk

Quick Start

import { TBUSDEscrow, ReleaseType } from '@tbusd/escrow-sdk';

// Read operations (no API key needed)
const escrow = new TBUSDEscrow();

// Check API health
const health = await escrow.health();
console.log(`Total escrows: ${health.totalEscrows}`);

// Get escrow details
const details = await escrow.getEscrow('0x8920107b0057ad179c45FBF29b6D22AB176b0058');
console.log(`Status: ${details.status}, Amount: ${details.amount} TBUSD`);

// Write operations (requires API key)
const escrowWithKey = new TBUSDEscrow({
  apiKey: 'your-api-key'
});

// Create a simple escrow
const result = await escrowWithKey.createEscrow({
  buyer: '0xBuyerAddress...',
  seller: '0xSellerAddress...',
  amount: '100',
  releaseType: ReleaseType.Mutual,
  description: 'Payment for freelance work'
});
console.log(`Created escrow: ${result.escrowAddress}`);

API Reference

Constructor

const escrow = new TBUSDEscrow({
  apiKey?: string,     // Required for write operations
  baseUrl?: string     // Default: 'https://tbusd.io/escrow-api'
});

Read Operations

These don't require an API key:

| Method | Description | |--------|-------------| | health() | API health check and stats | | getFactory() | Factory contract info | | listEscrows() | List all escrows (last 100) | | getEscrow(address) | Get escrow details | | getEscrowsByWallet(wallet) | Get escrows by wallet |

Write Operations

These require an API key:

| Method | Description | |--------|-------------| | createEscrow(params) | Create simple escrow | | createCustomEscrow(params) | Create with all options | | acceptArbitratorRole(address) | Accept arbitrator role | | acceptTerms(address) | Accept terms | | deposit(address) | Deposit funds | | approveRelease(address) | Release to seller | | approveRefund(address) | Refund to buyer | | raiseDispute(address) | Raise dispute |

Types

enum ReleaseType {
  Mutual = 0,         // Both parties must approve
  BuyerProtected = 1, // Buyer can refund anytime
  SellerProtected = 2,// Seller can release anytime
  TimeLocked = 3      // Auto-release after deadline
}

enum ArbitrationMode {
  None = 0,           // No arbitration
  Optional = 1,       // Can raise dispute
  Required = 2        // Arbitrator must confirm
}

Static Helpers

TBUSDEscrow.isTerminal(status)  // Released, Refunded, or Cancelled
TBUSDEscrow.isActive(status)    // Funded or Disputed
TBUSDEscrow.isPending(status)   // PendingAcceptance or AwaitingDeposit

AI Agent Example

import { TBUSDEscrow } from '@tbusd/escrow-sdk';

// AI agent managing escrows
class EscrowAgent {
  private sdk: TBUSDEscrow;

  constructor(apiKey: string) {
    this.sdk = new TBUSDEscrow({ apiKey });
  }

  async findActiveEscrowsForUser(wallet: string) {
    const { asBuyer, asSeller } = await this.sdk.getEscrowsByWallet(wallet);
    const allAddresses = [...new Set([...asBuyer, ...asSeller])];

    const activeEscrows = [];
    for (const addr of allAddresses) {
      const details = await this.sdk.getEscrow(addr);
      if (TBUSDEscrow.isActive(details.status)) {
        activeEscrows.push(details);
      }
    }
    return activeEscrows;
  }

  async createPaymentEscrow(buyer: string, seller: string, amount: string) {
    return this.sdk.createEscrow({
      buyer,
      seller,
      amount,
      description: `AI-created payment escrow for ${amount} TBUSD`
    });
  }
}

Contracts

| Contract | Address | |----------|---------| | Factory | 0x1fFA195A86d7E7872EBC2D1d24899addD3f1eB8c | | TBUSD | 0x0d02E2E2a7ADaF2372ca0C69845c8b159A24a595 |

Network: Base Mainnet

License

MIT